Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: wtbrannan on February 09, 2010, 04:02:31 am
-
Hello,
I have seen the other posts and I know it's sort of been addressed but I believe I have everything in order but can't seem to get past this error.
Here is what I have
Using code::blocks with GNU gcc Compiler
I have a header file (vacapi.h) and a library(libvac.a) provided by an SDK.
I have included the following in my Linker settings
pthread
X11
Xv
Xext
../Path/To/lib/libvac.a
I have also included the following in my Search Directories
../usr/include/X11
../Tools/SDKFolder/include [THIS IS WHERE the vacapi.h file is located]
../Tools/SDKFolder/lib [THIS IS WHERE the libvac.a file is located]
When I attempt to make a build I get the following.
-------------- Build: Debug in MyProject ---------------
g++ -Wall -fexceptions -Wall -g -I../../../../usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -I../../../../usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -c /home/billbrannan/Dev/MyProject/PktParser.cpp -o obj/Debug/PktParser.o
g++ -Wall -fexceptions -Wall -g -I../../../../usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -I../../../../usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -c /home/billbrannan/Dev/MyProject/OverlayEng.cpp -o obj/Debug/OverlayEng.o
g++ -Wall -fexceptions -Wall -g -I../../../../usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -I../../../../usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -c /home/billbrannan/Dev/MyProject/main.cpp -o obj/Debug/main.o
g++ -Wall -fexceptions -Wall -g -I../../../../usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -I../../../../usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -c /home/billbrannan/Dev/Common/Markup.cpp -o obj/Debug/Common/Markup.o
g++ -Wall -fexceptions -Wall -g -I../../../../usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -I../../../../usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -c /home/billbrannan/Dev/Common/c_serial_port.cc -o obj/Debug/Common/c_serial_port.o
g++ -o bin/Debug/MyProject obj/Debug/PktParser.o obj/Debug/OverlayEng.o obj/Debug/main.o obj/Debug/Common/Markup.o obj/Debug/Common/c_serial_port.o -lpthread -lX11 -lXv -lXext ../Tools/SDKFolder/lib/libvac.a -lpthread -lX11 -lXv -lXext ../Tools/SDKFolder/lib/libvac.a
obj/Debug/OverlayEng.o: In function `OverlayEng::Init()':
/home/billbrannan/Dev/MyProject/OverlayEng.cpp:102: undefined reference to `InitVAC(unsigned long, _XDisplay*)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 2 seconds)
1 errors, 0 warnings
Any help is greatly appreciated,
Thanks,
Bill
-
../Tools/SDKFolder/lib/libvac.a
Add the library "vac" to library list
Add the path "../Tools/SDKFolder/lib/" to search linker list.
rebuild project.
Tim S.
-
Tim,
Thank you very much but I am still getting the same error.
To be sure I did the right steps here is what I did.
I changed "../Tools/SDKFolder/lib/libvac.a" to "vac" in my Linker Settings (Under all 3 Scopes - Project - Debug - Release)
I added "../Tools/SDKFolder/lib" to Search Directories -> Linker Tab (Under all 3 Scopes - Project - Debug - Release)
Build-> Clean (just to be certain)
Build-> Rebuild
Thanks,
Bill
-
I don't see a build log.
Note to all beginners: The order the libraries are in makes a difference to whether it will link right.
In MinGW GCC try moving the Libraries with the link errors to the top of the "Link Libraries" list.
Note: Adding the same libraries many times makes it harder to understand the build log.
Add all the Libraries ONLY to the project Scope/Target till your learn the right way to do the adding.
Tim S.
-
Thanks.
I changed the scopes and will now start manipulating Link orders.
Here is the last build log.
Thanks again Tim. You've been very helpful.
-------------- Build: Debug in MyProject ---------------
g++ -Wall -g -I/usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -c /home/billbrannan/Dev/MyProject/PktParser.cpp -o obj/Debug/PktParser.o
g++ -Wall -g -I/usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -c /home/billbrannan/Dev/MyProject/OverlayEng.cpp -o obj/Debug/OverlayEng.o
g++ -Wall -g -I/usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -c /home/billbrannan/Dev/MyProject/main.cpp -o obj/Debug/main.o
g++ -Wall -g -I/usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -c /home/billbrannan/Dev/Common/Markup.cpp -o obj/Debug/Common/Markup.o
g++ -Wall -g -I/usr/include/X11 -I../Tools/SDKFolder/include -I../Tools/SDKFolder/lib -c /home/billbrannan/Dev/Common/c_serial_port.cc -o obj/Debug/Common/c_serial_port.o
g++ -L../Tools/SDKFolder/lib -L/usr/lib -o bin/Debug/MyProject obj/Debug/PktParser.o obj/Debug/OverlayEng.o obj/Debug/main.o obj/Debug/Common/Markup.o obj/Debug/Common/c_serial_port.o -lpthread -lX11 -lXv -lXext -lvac
obj/Debug/OverlayEng.o: In function `OverlayEng::Init()':
/home/billbrannan/Dev/MyProject/OverlayEng.cpp:102: undefined reference to `InitVAC(unsigned long, _XDisplay*)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 2 seconds)
1 errors, 0 warnings
-
Hello Tim,
I believe I found it. The solution seems so simple but just one of those "beginner" omissions.
Note for everyone else:
If your program is written in C++ and the lib is in C, then you must wrap the #include statement with extern "C" {[include.h file]}
Thanks for your help once again.
Bill