Connecting Tech Pros Worldwide Forums | Help | Site Map

New to C, "Undefined reference's"

steve
Guest
 
Posts: n/a
#1: Dec 2 '07
Hi, I am trying to compile a sample program using gcc. The program
requires headers so I put the header files and corresponding source
files into one folder. Then I ran the command 'gcc prog.c -o
prog.exe.' It then gives me errors such as "undefined reference to
'_N_VNew'" where N_VNew is in the header files I put in the folder.
Usually gcc file.c -o file.exe worked for a c program that include no
user defined headers. I've never dealt with headers before, is there
some gcc command I need to use? btw, I doubt there is a problem in the
source code calling the headers.

Thank You

Richard Heathfield
Guest
 
Posts: n/a
#2: Dec 2 '07

re: New to C, "Undefined reference's"


steve said:
Quote:
Hi, I am trying to compile a sample program using gcc. The program
requires headers so I put the header files and corresponding source
files into one folder. Then I ran the command 'gcc prog.c -o
prog.exe.' It then gives me errors such as "undefined reference to
'_N_VNew'" where N_VNew is in the header files I put in the folder.
Usually gcc file.c -o file.exe worked for a c program that include no
user defined headers. I've never dealt with headers before, is there
some gcc command I need to use? btw, I doubt there is a problem in the
source code calling the headers.
You have asked question 13.25 in the comp.lang.c FAQ, which can be found at
http://c-faq.com/

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
steve
Guest
 
Posts: n/a
#3: Dec 2 '07

re: New to C, "Undefined reference's"


Can someone give me an example, for instance, if I declare #include
"aheader.h" in my program and aheader.h is in the same folder of
myprog.c. I am in windows so I want to essentially run gcc myprog.c -o
myprog.exe to make an exe file.

Thank You
Richard Heathfield
Guest
 
Posts: n/a
#4: Dec 2 '07

re: New to C, "Undefined reference's"


steve said:
Quote:
Can someone give me an example, for instance, if I declare #include
"aheader.h" in my program and aheader.h is in the same folder of
myprog.c. I am in windows so I want to essentially run gcc myprog.c -o
myprog.exe to make an exe file.
This is not a header issue, as the FAQ I told you about should have made
abundantly clear to you. "Undefined reference" generally means you've
forgotten to link a library (although that is not the only possible cause
of that message, it would seem to be the cause in this case, from what
you've said so far).

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Mark McIntyre
Guest
 
Posts: n/a
#5: Dec 2 '07

re: New to C, "Undefined reference's"


steve wrote:
Quote:
Hi, I am trying to compile a sample program using gcc. The program
requires headers so I put the header files and corresponding source
files into one folder. Then I ran the command 'gcc prog.c -o
prog.exe.' It then gives me errors such as "undefined reference to
'_N_VNew'" where N_VNew is in the header files I put in the folder.
The header only contains the declaration of that type. The definition is
in some library. There's a FAQ which is relevant to this.

By the way, you have a Greengrocer's apostrophe in your subject. Plurals
do not generally require apostrophes.
Closed Thread