LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-10-2004, 07:26 AM   #1
george_mercury
LQ Newbie
 
Registered: Jun 2004
Location: Slovenia
Distribution: Gentoo
Posts: 27

Rep: Reputation: 15
Undefined reference, why?


Hi,
Im working on a project to interface a simple USB chip, but this really isn't important in this case. The problem is that I cannot compile, because I get an "Undefined rereference to 'ftdi_init' error. ftdi_init is a function.

Here's my case. I've got two libraries, one called ftdilib library, which needs the usblib library. I've installed both libraries in the standard way ( tar, configure, make, make install ). Here is what doesn't compile:

#include <ftdi.h>
#include <usb.h>

int main(int argc , char *argv[])
{
ftdi_init(&variable);
return 0;
}

If I compile this I get an error: Undefined reference to 'ftdi_init'. I've checked ftdi.h and the ftdi_init declaration is in it. The ftdi.c file also contains the code for ftdi_init function. However, I couldn't find any #include <ftdi.c> in the ftdi.h.

So what are the most frequent causes for errors like mine?

George Mercury
 
Old 07-10-2004, 07:42 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
Maybe you have to explicitly link the library like :
gcc -lftdi -o program program.c
 
Old 07-13-2004, 04:47 PM   #3
george_mercury
LQ Newbie
 
Registered: Jun 2004
Location: Slovenia
Distribution: Gentoo
Posts: 27

Original Poster
Rep: Reputation: 15
Thanks that worked! It compiled successfully. However, I've got one more problem. The library install ( configure, make, make install ) does not seem to work. When I compile and run the program I get an error: error loading shared libraries libftdi.so.0: cannot open shared library object: No such file or directory.
So which files do I need of linux to see them?

Thanks for all the help,
George Mercury

Last edited by george_mercury; 07-13-2004 at 04:53 PM.
 
Old 07-14-2004, 02:08 AM   #4
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
umm where is this library being installed..you have to specify this at gcc command line as -L option to tell the linker where it has to look for the library in addition to the standard library locations like /usr/lib, /lib, et al...try to put your library in the standard path ...if it has been compiled and generated properly after make, make install ..and stuff
this is how you might need the command to look like....

gcc -L <where lftdi resides> -lftdi <xyz.c>
 
Old 05-07-2009, 01:15 AM   #5
joseluiselaprendizcol_
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 0
Similar problem

Hello, I have a similar problem, something can help me with this question, is possible to obtain a share library that have errors? that is, g++ to stop the construction of the share libraries when this found an error ? or this can to continue the building of the share library with errors,thanks in advance, if the answers is yes, i have a big problem because g++ don't show where the library have erros.
 
  


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 reference to `XF86VidModeGetModeLine' apokryphos Linux - General 1 08-07-2005 07:40 PM
Undefined Reference ChemicalBurn Programming 2 02-14-2005 04:01 AM
undefined reference mp4-10 Programming 3 01-25-2005 01:38 PM
undefined reference to 'request_irq()' deimosSan Programming 2 11-10-2003 09:15 AM
Yet another 'undefined reference' problem faulpelz2 Linux - Software 3 04-04-2003 12:18 PM


All times are GMT -5. The time now is 03:43 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration