LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 11-15-2009, 10:42 PM   #1
Tim-Deale
LQ Newbie
 
Registered: Nov 2009
Location: Maryland
Distribution: Fedora 10 currently
Posts: 3

Rep: Reputation: 1
Header file problem - SVGAlib


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:

/usr/src/kernels/2.6.27.38-170.2.113.fc10.i686/include/video

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

vga_init(); // initialize VGA graphics
vga_setmode(1); // 320 x 200 pixels, 16 colors

vga_setmode(TEXT); // change back to text display

return 0;
}
 
Old 11-16-2009, 01:21 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
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.
 
Old 11-16-2009, 09:40 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
.
# yum -y install svgalib-devel

.. will provide the headers ' vga.h ' etc.
.. and usr/lib/libvga.so .
 
Old 11-30-2009, 08:09 PM   #4
Tim-Deale
LQ Newbie
 
Registered: Nov 2009
Location: Maryland
Distribution: Fedora 10 currently
Posts: 3

Original Poster
Rep: Reputation: 1
I'm back from a Thanksgiving trip.

I did install svgalib via yum - see initial posting. It still doesn't compile. Any other suggestions?
 
0 members found this post helpful.
Old 11-30-2009, 08:45 PM   #5
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
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.
 
0 members found this post helpful.
Old 12-01-2009, 03:38 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
Quote:
It still doesn't compile.
Missing svgalib-devel


Did you install the -devel package ? ?

.....
 
Old 12-02-2009, 11:27 PM   #7
Tim-Deale
LQ Newbie
 
Registered: Nov 2009
Location: Maryland
Distribution: Fedora 10 currently
Posts: 3

Original Poster
Rep: Reputation: 1
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?

Thanks in advance.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with netfilter header file arafat.sultan Programming 1 08-20-2009 12:42 PM
Problem with extern struct object, in header file. Undefined type. RHLinuxGUY Programming 7 07-24-2006 01:01 AM
Problem with c header file alaios Programming 4 09-03-2005 10:06 PM
Svgalib and Svgalib-devel on FC1 Michele Spinolo Fedora 1 11-11-2004 10:56 AM
SVGALib keyboard problem ChimpFace9000 Programming 0 05-15-2002 12:34 AM


All times are GMT -5. The time now is 09:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration