Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
I'm a newbie to Linux programming (I'm a hardware engineer by practice) - the last C programming I did was 10+ years ago... It was K&R C with a Borland IDE.
I'm using Fedora 10, programming using the Anjuta IDE (although I ran into the same problem with gcc at the shell). I have installed the SVGAlib library with Fedora's yum utility. It seems to have loaded without any problems. However, when I compile code to include the <vga.h> and/or the <svga.h> header file(s) I get the error:
main.c:21:17: error: vga.h: No such file or directory
I also get the warning:
main.c:29:warning: implicit declaration of function 'vga_init'
which I expect since the compiler didn't recognize the header file in the first place. I'm suspecting the compiler is expecting the header file to be located in the same location as the rest of the header files (/user/include) but it is not. When yum installed it, it was located at:
My question is "how can I explicitly state in my code to have the compiler look at the /user/src/kernels... location rather than the normal location for the header file?
For reference, below is my code. It's simple, just to test the compiling and see that it works... Of course it doesn't...
Can anyone help?
<><><><><><><><><>
#include <stdio.h>
#include <vga.h>
int main()
{
printf("Hello world.\n"); //started with this
//and added the following
gcc's -I option lets specify further directories to be searched for headers, e.g.
gcc stuff.c -o stuff -I/stuff
will look for headers in /stuff, in addition to the standard directories. I'm not sure where you set flags for gcc in Anjuta (or even set which compiler it's using, but it's most likely to be gcc), I'm afraid. You'll also need to link the SVGA library, for which you use -lvga, according to the tutorial on the SVGAlib website.
You should never use header files from the kernel for building external programs. This is a NO NO unless your building a driver for the running kernel. You should always use the sanitized ones that were used for building glibc. In your example you are trying to use vga.h and it is not being found. You probably don't have the library for it installed in your system. That or the development stuff is not there who knows. Install svgalib either from source or from the development package and this should clear things up.
OK, I found the problem, and the fix. Remember, I'm new to programming in the linux environment...
The way I found the fix was that I ran into the same problem with the math library using the sqrt() function. Web searches on that problem lead me to the solution. From the shell, using the gcc compiler, I needed to compile with the -lm option (linking in the libm.a library). Going back to the svgalib problem, I compiled with the -lvga option and it now all compiles just fine, no errors.
Now I want to use the Anjuta IDE. How do I tell the IDE to link using the -lm and -lvga options? Can anyone 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.