You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, July 22nd 2010, 11:30am

problem with QtCreator linking external static library on windows 7

Hi people,
I'm having lot of troubles trying to link a static library in a project developed in QtCreator but not using Qt libraries.
Due to some hardware restrictions, I'm working on Windows 7 with QtCreator 1.3.1 based on Qt 4.6.2 (32 bits).
I'm just trying to link an external library built in dev-c++, but I get errors. I have included in .pro file the tag

Source code

1
LIBS += .\liburbi.a .\libjpeg.a -lws2_32 -lgdi32 -g3
in several formats (absolute paths, relative paths, -L[dir] -l[libname without extension and with out lib at the beginning], etc...) but it doesn't work.

The most wird for me is that if I open a command window, go to the directory where my project is, and type the commands qtcreator is trying to execute, it works!!! So I guess the problem isn't in the library. Even I've made a batch file for building my project and it runs from a command window but not from QtCreator when I added as the first build step.

As you can see, I'm a bit frustraeted and stuck, I don't know what else I can do, so I'm really considering to move to other IDE (in spite this is the most I like).

Following I copy the errors got from QtCreator (because of the long list, I've removed some of them in between).
Next, working lines executed from the batch file:

Source code

1
2
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_THREAD_SUPPORT -I"c:\Qt\2010.03\qt\include" -I"..\liburbi-cpp-0.9.3\src\liburbi" -I"c:\Qt\2010.03\qt\include\ActiveQt" -I"debug" -I"c:\Qt\2010.03\qt\mkspecs\win32-g++" -o debug\main.o main.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\QTtestingAIBO.exe debug/main.o .\liburbi.a .\libjpeg.a -lws2_32 -lgdi32 -g3



Any idea???Any suggestion??? HELP!!!
Thanks!


***************FOLLOWING ERRORS FROM QTCREATOR*********************

Ejecutando los pasos para construir el proyecto QTtestingAIBO... Iniciando: c:/qt/2010.03/qt/bin/qmake.exe C:/Users/alvarokas/Documents/workspace/QTtestingAIBO/QTtestingAIBO.pro -spec win32-g++ -r
Finalizado retornando 0.
Iniciando: C:/Qt/2010.03/mingw/bin/mingw32-make.exe -f Makefile.Debug -w
mingw32-make: Entering directory `C:/Users/alvarokas/Documents/workspace/QTtestingAIBO'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_THREAD_SUPPORT -I"c:\Qt\2010.03\qt\include" -I"..\liburbi-cpp-0.9.3\src\liburbi" -I"c:\Qt\2010.03\qt\include\ActiveQt" -I"debug" -I"c:\Qt\2010.03\qt\mkspecs\win32-g++" -o debug\main.o main.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\QTtestingAIBO.exe debug/main.o -L"c:\Qt\2010.03\qt\lib" -static .\liburbi.a .\libjpeg.a -lws2_32 -lgdi32 -g3
.\liburbi.a(uclient.o):uclient.cpp:(.text+0x130): undefined reference to `__gxx_personality_sj0'
.\liburbi.a(uclient.o):uclient.cpp:(.text+0x15e): undefined reference to `_Unwind_SjLj_Register'
.\liburbi.a(uclient.o):uclient.cpp:(.text+0x4f8): undefined reference to `_Unwind_SjLj_Resume'
.\liburbi.a(uclient.o):uclient.cpp:(.text+0x506): undefined reference to `_Unwind_SjLj_Unregister'
.\liburbi.a(uclient.o):uclient.cpp:(.text+0x524): undefined reference to `__gxx_personality_sj0'
.\liburbi.a(uclient.o):uclient.cpp:(.text+0x552): undefined reference to `_Unwind_SjLj_Register'
.\liburbi.a(uclient.o):uclient.cpp:(.text+0x92f): undefined reference to `_Unwind_SjLj_Resume'
....
....
....

.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text+0x60f6): undefined reference to `_Unwind_SjLj_Unregister'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text+0x610e): undefined reference to `__gxx_personality_sj0'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text+0x6133): undefined reference to `_Unwind_SjLj_Register'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text+0x61b5): undefined reference to `_Unwind_SjLj_Resume'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text+0x61c0): undefined reference to `_Unwind_SjLj_Unregister'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text+0x643a): undefined reference to `__gxx_personality_sj0'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text+0x6468): undefined reference to `_Unwind_SjLj_Register'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text+0x6540): undefined reference to `_Unwind_SjLj_Resume'
...
...
...
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text$_ZNSt10_List_baseI13UCallbackInfoSaIS0_EEC2ERKS1_[std::_List_base<UCallbackInfo, std::allocator<UCallbackInfo> >::_List_base(std::allocator<UCallbackInfo> const&)]+0xe0): undefined reference to `_Unwind_SjLj_Resume'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text$_ZNSt10_List_baseI13UCallbackInfoSaIS0_EEC2ERKS1_[std::_List_base<UCallbackInfo, std::allocator<UCallbackInfo> >::_List_base(std::allocator<UCallbackInfo> const&)]+0xeb): undefined reference to `_Unwind_SjLj_Unregister'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text$_ZNSt4listI13UCallbackInfoSaIS0_EE14_M_create_nodeERKS0_[std::list<UCallbackInfo, std::allocator<UCallbackInfo> >::_M_create_node(UCallbackInfo const&)]+0xc): undefined reference to `__gxx_personality_sj0'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text$_ZNSt4listI13UCallbackInfoSaIS0_EE14_M_create_nodeERKS0_[std::list<UCallbackInfo, std::allocator<UCallbackInfo> >::_M_create_node(UCallbackInfo const&)]+0x31): undefined reference to `_Unwind_SjLj_Register'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text$_ZNSt4listI13UCallbackInfoSaIS0_EE14_M_create_nodeERKS0_[std::list<UCallbackInfo, std::allocator<UCallbackInfo> >::_M_create_node(UCallbackInfo const&)]+0xc8): undefined reference to `_Unwind_SjLj_Resume'
.\liburbi.a(uabstractclient.o):uabstractclient.cpp:(.text$_ZNSt4listI13UCallbackInfoSaIS0_EE14_M_create_nodeERKS0_[std::list<UCallbackInfo, std::allocator<UCallbackInfo> >::_M_create_node(UCallbackInfo const&)]+0xd9): undefined reference to `_Unwind_SjLj_Unregister'
collect2: ld returned 1 exit status
mingw32-make: Leaving directory `C:/Users/alvarokas/Documents/workspace/QTtestingAIBO'
mingw32-make: *** [debug\QTtestingAIBO.exe] Error 1
Finalizado retornando 2.
Error durante la construcción del proyecto QTtestingAIBO
Mientras se ejecutaba la etapa 'Make'

2

Friday, July 23rd 2010, 1:16pm

I've found the problem. I was using two different compilers for building the library and for building the project. The one I used to build the library was in the path of the system, that's why it worked when I compiled and linked from the command line.
I've solved the problem as it is described in specifying the linker

Cheers!