How to attach new C header files and libraries in Linux
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[]) {
printf("SPAM! Line.\n");
fflush(stdout);
/* The system("clear")-call is interesting for you! */
system("clear"); // Calls "clear" in the console - for the system-call you need the stdlib.h
printf("New line\n");
fflush(stdout);
return EXIT_SUCCESS; // Linux-specific exit-code is in the stdlib.h
}
EDIT
In fact it doesn't clear the screen, it simply moves the "old" text to the top, so that the console seems to be cleared ...
With the following command you can move the cursur to the right upper corner of the screen. Then simply write lots of spaces and you have a really blanked screen.
Code:
printf("\033[1;1H");
Last edited by grisu42; 03-11-2010 at 08:16 AM.
Reason: addition
i know where i put the conio library but someone else in the forum stated that there is a standard location in which library files are usually stored.. i want to know what that library file is..
i know the following might sound a little naive.. but the thing is, the tarball i downloaded contained SO many files and conio.h was one file among them.. what exactly do i consider to be the library file? is there some process where i'm expected to concatenate all these files into forming one "library" file? or can the conio.h file be directly used?
I would also like some direction as to where i could find a comprehensive tutorial of the very basics of linux as i feel that all these problems are a result me not understanding how linux works..
If i'm not crossing the line here.. how did YOU guys get acquainted with Linux?
Hi again,
as I already said, libraries are usually located in the /lib directory in Linux. Libraries usually contain a *.so.* extension. Look in your files that match that pattern and try copying them into the /lib directory. You might have to run ldconfig afterwards, I am not 100% sure about that.
P.S.: The pattern for the libraries I posted above is valid for shared libraries. There are also static libraries which end on *.a
To make that one available to your system you'd go
Code:
cd libconio-1.0.0 && ./configure && make && make install
To then compile your code:
Code:
gcc -L/usr/lib -lconio -o helloWorld helloWorld.c
Quote:
If i'm not crossing the line here.. how did YOU guys get acquainted with Linux?
Very much like riding a bike; just hop on and try.
And with these words, I'd like to refer back to post #14 by paulsm4 ...
you'd really be better off trying to use something more Linuxy as learning
material if this is what you're after.
I really hate to see you spin your wheels, and I'm very much afraid that might be what's happening.
Q: what is it you're trying to do?
Q: If you're just experimenting with some sample code that happened to use "conio.h", could you please tell us a little bit more about it. For example, where did you get it? Or what is it about the code that interested you?
'Cos here's the deal: "conio.h" is a relic of DOS; a throwback to the late 1980's. If, for whatever reason, the program that uses it is useful to you - cool. We can give you a workaround. But if it's just some "sample code" you wanted to experiment with - heck, we can probably point you in a MUCH better direction.
Either way, please give us a bit more context about what you actually need - and we'd be happy to help.
Anytime!
Sincerely .. PSM
hi paulsm4,
Well i guess you're absolutely right, i AM simply trying on a bit of code to just figure out how things work in Linux, I'm really new to the whole concept of manually linking and "make"ing files. It's not that is was trying sample code, I was just going step by step, increasing the level of complexity of the code to see what kinda errors i would encounter..
I first started with a simple "printf" program, then tried importing other standard libraries such as "string.h" and "ctype.h" to see if the same functions were available. THEN i imported the conio.h library simply to CLEAR THE SCREEN / TERMINAL using clrscr() this is where i got stuck.. in the beginning i had no idea that conio.h wasn't a linux library, then i read around using google and found a library for linux that mimics the conio.h library, and was unable to link it to the program that i was writing.
Well i've seen in this thread that the conio.h is relic and that i shouldn't really use it... well i agree with that but i guess what my problem ACTUALLY is...
How do i link a non-standard library / header file to a C program that i'm writing? i wouldn't have to be conio.h, what if wrote my own header file? what do i need to do to attach to ANOTHER program in order to use any functions that i've written in it?
To make that one available to your system you'd go
Code:
cd libconio-1.0.0 && ./configure && make && make install
To then compile your code:
Code:
gcc -L/usr/lib -lconio -o helloWorld helloWorld.c
Very much like riding a bike; just hop on and try.
And with these words, I'd like to refer back to post #14 by paulsm4 ...
you'd really be better off trying to use something more Linuxy as learning
material if this is what you're after.
Cheers,
Tink
hi Tinkster!!
Yeah this is exactly what I got!! while thanking you for the help, i would REALLY appreciate it if you could give me a VERY brief explanation as to why all these files are needed... why can't a single header file be pasted in the same folder as the ".c" file and included and used in the program like in windows? what is it that happens differently in Linux? i know you're against spoon feeding through your end line after each post i'm not into it myself hehe.. but it helps sometimes to get insight from a source that has SOME idea of the level and context of the reader
Yeah this is exactly what I got!! while thanking you for the help, i would REALLY appreciate it if you could give me a VERY brief explanation as to why all these files are needed... why can't a single header file be pasted in the same folder as the ".c" file and included and used in the program like in windows?
It's been a LONG time that I've last used a windows
compiler; but I assure you that a simple 'header' file
compiled against a .c file won't render anything useful
unless you a) have the full source that belongs with the
header in the same dir, or b) have a library (DLL) to go
with it.
Quote:
Originally Posted by zeezulander
what is it that happens differently in Linux? i know you're against spoon feeding through your end line after each post i'm not into it myself hehe.. but it helps sometimes to get insight from a source that has SOME idea of the level and context of the reader
You don't need ALL those files. It's just that these things
are written to be portable; and a library compiled for a
machine using e.g. libc-2.1 on an ARM based computer won't
be doing you any good if your machine is x86 and using
libc-2.3, for example. To BUILD the library that you can
use with your header for a local project on your machine
everything required to build it is provided. Hence the
'abundance of files'. In the install you'll most likely
only end up with the header, the lib and maybe the man-
pages; perfectly sane.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.