LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Undefined reference, why? (http://www.linuxquestions.org/questions/programming-9/undefined-reference-why-203329/)

george_mercury 07-10-2004 06:26 AM

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

keefaz 07-10-2004 06:42 AM

Maybe you have to explicitly link the library like :
gcc -lftdi -o program program.c

george_mercury 07-13-2004 03:47 PM

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

shishir 07-14-2004 01:08 AM

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>

joseluiselaprendizcol_ 05-07-2009 12:15 AM

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.


All times are GMT -5. The time now is 12:34 AM.