LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 01-19-2011, 03:12 AM   #1
Kanangill
LQ Newbie
 
Registered: Jan 2011
Posts: 5

Rep: Reputation: 0
Issues with undefined references and linking in WordNet


Hey all,
I'm writing a C program using WordNet, just a very basic one to test out if everything was working fine, but I'm getting undefined references. I linked to the library and compile with

Code:
gcc prog.c -L/usr/local/WordNet-3.0/lib/libWN.a -I/usr/local/WordNet-3.0/include/
This seems to be the only wordnet library to link to, but I'm still getting the error

Code:
/tmp/cc4C3I3S.o: In function `main':
prog.c:(.text+0x21): undefined reference to `is_defined'
prog.c:(.text+0x48): undefined reference to `findtheinfo'
collect2: ld returned 1 exit status
I feel it must be an error with the way I'm going about trying to link the files. Sorry if the question is too simplistic for the forum, I'm genuinely stumped!
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 01-19-2011, 03:42 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
The -L option serves to specify a directory to be searched for libraries specified with the -l option. In the -l option the name of the library must be written without the leading lib and without extension. The following should work:
Code:
gcc -I/usr/local/WordNet-3.0/include prog.c -L/usr/local/WordNet-3.0/lib -lWN
Hope this helps.
 
2 members found this post helpful.
Old 01-19-2011, 09:25 AM   #3
Kanangill
LQ Newbie
 
Registered: Jan 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Talking

Thank you so much for the help. That solves my problem. Just curious, but does the order of the arguments make a difference?
Such as giving the include and link option and the name of the after both of those. A link I found on the internet says that the order of specification is important for 'some linkers'.
So which linkers? Thanks in advance (and with some hope)
 
Old 01-19-2011, 12:02 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
You're welcome!
Quote:
Originally Posted by Kanangill View Post
Thank you so much for the help. That solves my problem. Just curious, but does the order of the arguments make a difference?
Such as giving the include and link option and the name of the after both of those. A link I found on the internet says that the order of specification is important for 'some linkers'.
So which linkers? Thanks in advance (and with some hope)
Yes. I'd say the same: it is important for some linkers but I can't tell anything more either. I have encountered some problem using the proprietary Solaris fortran compiler (and linker) in the past, but I'm not sure about the exact issue.

Recently I encountered a problem compiling a fortran code against the grib_api libraries (grib is a file format specific for atmospheric model data). The order by which I specify the two libraries to link against is important, e.g.
Code:
pgf95 blah blah blah -L/lhome/swan/roms/grib_api-1.9.0/lib -lgrib_api_f90 -lgrib_api
works, whereas
Code:
pgf95 blah blah blah -L/lhome/swan/roms/grib_api-1.9.0/lib -lgrib_api -lgrib_api_f90
does not, most likely for the crossed references between the two libraries. Anyway, if I put the -I option, the code to compile and the -L option in this order is a habit for me. Trying to change this order is just something to remember in case of problems.
 
Old 01-20-2011, 10:19 AM   #5
Kanangill
LQ Newbie
 
Registered: Jan 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks again, that seems like good programming practice then.
 
  


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
undefined references when compiling PLIB program Alkibiades Programming 3 03-13-2010 03:18 PM
Undefined references with static libraries Nightfox Programming 2 10-28-2005 07:43 PM
texinfo - undefined references during make fitret Linux - Software 1 06-18-2005 03:38 PM
Qt 3.3.3 undefined references when linking Ch. 7 tutorial QtCoder Programming 3 11-07-2004 12:59 PM
why compiler gives undefined references on static members??? Hano Programming 8 06-26-2002 12:12 PM


All times are GMT -5. The time now is 02:47 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