25an
February 7th, 2008, 09:42 PM
Hi
I am having some problems linking a c library with my c++ application. I have written the c library on my own and managed to link it with a c application now I would like to link it with my c++ application. I have included in the c library h-file the syntax
#ifdef __cplusplus
extern "C" {
#endif
..
...
.....
...
#ifdef __cplusplus
}
#endif
so the entire contents of the h-file is inside the extern "C" declaration according to tutorials on the net. Next step is the compilation and linking, the commands I am using is
g++ -o framebuffer.o -c -Wall -L./lib -I./include framebuffer.cc
g++ -o fb_main.o -c -Wall -L./lib -I./include fb_main.cc
gcc framebuffer.o fb_main.o -lstdc++ -lmikrofb -o fb_main
but I can't link it with gcc I always get the error
gcc framebuffer.o fb_main.o -lstdc++ -lmikrofb -o fb_main
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [fb_main] Error 1
If I use g++ instead I get the error
-lstdc++ -lmikrofb -o fb_main
/usr/bin/ld: cannot find -lmikrofb
collect2: ld returned 1 exit status
Any help is appreciated
I am having some problems linking a c library with my c++ application. I have written the c library on my own and managed to link it with a c application now I would like to link it with my c++ application. I have included in the c library h-file the syntax
#ifdef __cplusplus
extern "C" {
#endif
..
...
.....
...
#ifdef __cplusplus
}
#endif
so the entire contents of the h-file is inside the extern "C" declaration according to tutorials on the net. Next step is the compilation and linking, the commands I am using is
g++ -o framebuffer.o -c -Wall -L./lib -I./include framebuffer.cc
g++ -o fb_main.o -c -Wall -L./lib -I./include fb_main.cc
gcc framebuffer.o fb_main.o -lstdc++ -lmikrofb -o fb_main
but I can't link it with gcc I always get the error
gcc framebuffer.o fb_main.o -lstdc++ -lmikrofb -o fb_main
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [fb_main] Error 1
If I use g++ instead I get the error
-lstdc++ -lmikrofb -o fb_main
/usr/bin/ld: cannot find -lmikrofb
collect2: ld returned 1 exit status
Any help is appreciated