Results 1 to 4 of 4
Code:
#include "cgnslib.h"
main()
{
int fn;
cg_open("demo.cgns",CG_MODE_WRITE,&fn);
cg_close(fn);
}
Output of the program:
/tmp/ccYWbQxX.o: In function `main':
demo.c .text+0x2 : undefined reference to `cg_open'
demo.c .text+0x33): undefined reference to ...
- 06-16-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 2
undefined reference to 'function' error in gcc
Output of the program:Code:#include "cgnslib.h" main() { int fn; cg_open("demo.cgns",CG_MODE_WRITE,&fn); cg_close(fn); }
/tmp/ccYWbQxX.o: In function `main':
demo.c
.text+0x2
: undefined reference to `cg_open'
demo.c
.text+0x33): undefined reference to `cg_close'
collect2: ld returned 1 exit status
Thanks.
- 06-16-2008 #2
At compile time, the #include "cgnslib.h" lets the compiler know what the calling interface for each function in the CGNS library, so the compiler can compile your calls to that library correctly.
But at link time, the linker needs to have access to the actual compiled library; otherwise, your program doesn't include the actual CGNS code.
I've never used CGNS, but if you've installed it correctly, you'll know where the library is stored and what it is named. You should change your gcc command to include the name (and possibly the directory path) of the compiled library. Your gcc command might look something like this:
Code:gcc sample.c libgcc.a -o sample
--
Bill
Old age and treachery will overcome youth and skill.
- 06-16-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 2
Thank you very much!
- 07-21-2008 #4Just Joined!
- Join Date
- Jul 2008
- Posts
- 1
wje_lf thanks a lot, we are newbies on linux, and nobody say nothing =( you information was helpfull for using libserial with anjuta <--
just add this ==>CXX = g++ /usr/local/lib/libserial.la<== on makefile or when compile... Thanks


