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.
How to attach new C header files and libraries in Linux
Hi,
I have been a predominant Windows user for a long time but shifted to Ubuntu recently. I was just trying out a few basic C functions when i realized that the "conio.h" header file isn't included in the libraries and therefore i was unable to use the "clrscr()" function.
I downloaded a tarball which contained the necessary library and header files including conio.h. Once extracted, i specified the location and included in the program as " #include "path to the header file" ".
I still didn't call the "clrscr()" function, and it compiled successfully. Next i edited the program to call that function and it gave the following error...
" zeezulander@ZeeZuLander:~$ gcc helloWorld.c
/tmp/ccshJs6b.o: In function `main':
helloWorld.c.text+0xa): undefined reference to `clrscr'
collect2: ld returned 1 exit status "
Could someone point out where I've made the mistake and how it could be rectified? and if possible an explanation as to how i can add new libraries in the future?
There *is* no "clrscr" function, nor any "conio.h" header ... for the simple reason that they're obsolete artifacts from DOS. Last I looked, they were available in Windows, but purely for legacy reasons: they're certainly *not* part of the Windows API.
I would strongly discourage you from using anything from "conio.h", even if you did find a wrapper. Unless, of course, you're truly programming for DOS
Otherwise, I would encourage you to explore ncurses (for Linux text-mode), or something like Qt, GTK+ or SDL (for Linux GUIs).
Where ever you put the conio library - we wouldn't know.
hi again..
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?
The conio.h is a header file. It will be associated with a c library file which you don't want to use.
You need to rewrite your sample code or use a different book. There are plenty gcc C programming books. I'd recommend "Linux Programming by Example" published by Prentice Hall.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.