![]() |
| | #1 |
| Registered User Join Date: Aug 2009
Posts: 107
| error (.text+0x *) undefined reference to ' ' need help Code: #include <stdio>
int main( int ....., char** .....) {
printf(hi\n);
}
/root/Desktop/Vmainline/fctl/ fctl.c uses a function from Vmain/v2lin_v02/lib like semGive(); so i use the command gcc -I../../v2lin_v02/lib -I/root/Desktop/VMainlineV3/h -lm -o main *.c *.h -L../../v2lin_v02/lib and i get a whole bunch of errors basically looking like this fctl.c .text+0x16a): undefined reference to `semGive'and i know theres some kind of link cuz without the -I../../ v2lin.......... blah blah i would actually get a error saying semGive() undeclared or something so is there another way to link it or am i missing something And i even loaded the library from v2lin_v02/lib by export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/Desktop/VMainlineV3/v2lin_v02/lib |
| kiros88 is offline | |
| | #2 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,368
| Who wrote the "huge amount of code"? You might want to ask the author for help, read documentation, etc. If you wrote it, then I think that we should start by helping you fix your code, since at a glance it probably has alot of errors.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is offline | |
| | #3 |
| Registered User Join Date: Sep 2004 Location: California
Posts: 2,845
| Where is semGive() implemented? Is there a .c file somewhere, or is it in a library?
__________________ bit∙hub [bit-huhb] n. A source and destination for information. |
| bithub is offline | |
| | #4 |
| Registered User Join Date: Aug 2009
Posts: 107
| semGive() is like under semlib.c and a header for it is semlib.h and thats in VmainV3/ v2lin_v02/lib both of them and im compiling in VmainV3/fabric/fctl |
| kiros88 is offline | |
| | #5 |
| Registered User Join Date: Sep 2004 Location: California
Posts: 2,845
| Well that's your problem then. You probably need to compile the code in VmainV3/v2lin_v02/lib to a library, and then link to that library when you compile what's in fctl.
__________________ bit∙hub [bit-huhb] n. A source and destination for information. |
| bithub is offline | |
| | #6 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| So, do you have a libsem.a, or a semlib.o, or something? If all you have is a .c file, then you need to compile it just like you compile everything else. If you have a .a file, you need to add the library with -lsem (or whatever the thing is called). |
| tabstop is offline | |
| | #7 |
| Registered User Join Date: Aug 2009
Posts: 107
| okay so i do compile the code in that lib directory i get a libv2lin.so libv2linmain.so then i just do export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/Desktop/VMainlineV3/v2lin_v02/lib and it works fine cuz i had a test folder /root/Desktop/VMainV3/v2lin_v02/samples/with_main and in that folder it had a program with_main.c and it compiled and ldd with_main linux-vdso.so.1 => (0x00007fff3bfff000) libv2lin.so => /root/Desktop/VMainlineV3/v2lin_v02/lib/libv2lin.so (0x00007fc333b68000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc33394c000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fc333748000) librt.so.1 => /lib64/librt.so.1 (0x00007fc33353f000) libc.so.6 => /lib64/libc.so.6 (0x00007fc3331e6000) /lib64/ld-linux-x86-64.so.2 (0x00007fc333d75000) |
| kiros88 is offline | |
| | #8 |
| Registered User Join Date: Aug 2009
Posts: 107
| i get a semLib.o in the v2lin_v02/lib |
| kiros88 is offline | |
![]() |
| Tags |
| code, link |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting an error with OpenGL: collect2: ld returned 1 exit status | Lorgon Jortle | C++ Programming | 6 | 05-08-2009 08:18 PM |
| Undefined Reference Compiling Error | AlakaAlaki | C++ Programming | 1 | 06-27-2008 11:45 AM |
| Screwy Linker Error - VC2005 | Tonto | C++ Programming | 5 | 06-19-2007 02:39 PM |
| C OpenGL Compiler Error? | Matt3000 | C Programming | 12 | 07-07-2006 04:42 PM |
| c++ linking problem for x11 | kron | Linux Programming | 1 | 11-19-2004 10:18 AM |