PDA

View Full Version : Qt + boost + MinGW on Windows



akos.maroy
12th June 2008, 12:39
I'm trying to create a build environment which would include Qt 4.3 and boost 1.35.0 on both Linux and Windows, using Eclipse CDT as a common IDE on both platforms. On Linux things are quite straighforward, one just installs Eclipse CDT, the Qt-Eclipse integration plugin, and then everything compiles and links fine with the system supplied gcc and system installed boost libraries.

But on Windows, I'm getting into issues. There I also downloaded Eclipse CDT, the Qt-Eclipse integration pluign, Qt itself, which in turn downloads a specific version of MinGW it likes. I can import and compile the source code samples that come with Qt with this setup.

But I'm having trouble integration boost into the mix. I tried several approaches.

Trying to link boost that was compiled for Visual C++

First I downloaded the binary boost package compiled for Windows from Boost Consulting (http://www.boost-consulting.com/products/free). It installs fine, and if I add the appropriate directory the include files are found. But, I can't link to any of the boost libraries provided, even if I supply the library path and the name of the library appropriately in the project file as:

LIBS+= -Lc:\usr\boost\boost_1_35_0\lib -lboost_date_time-vc90-mt-1_35

seemingly the symbols that are supposed to be in the library are not found by the MinGW linker:


g++ -enable-stdcall-fixup -Wl,-enable-auto-import
-Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl
-Wl,-subsystem,windows -o release\hello_boost_opengl.exe
release/BoostTime.o release/GlWidget.o release/main.o release/MainWindow.o
release/moc_GlWidget.o release/moc_Mainwindow.o -L"c:\usr\Qt\4.3.5\lib"
-lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmain
-lboost_date_time-vc80-mt-1_35 -Lc:\usr\boost\boost_1_35_0\lib -lQtOpenGL4
-lQtGui4 -lQtCore4
release/BoostTime.o(.text$_ZN5boost9gregorian21to_simple_s tring_typeIcEESbIT_St11char_traitsIS2_ESaIS2_EERKN S0_4dateE[std::basic_string<char,
std::char_traits<char>, std::allocator<char> >
boost::gregorian::to_simple_string_type<char>(boost::gregorian::date
const&)]+0x1b3):BoostTime.cpp: undefined reference to
`boost::gregorian::greg_month::as_short_string() const'
collect2: ld returned 1 exit status


Trying to use MinGW from nuwen.net

As an alternative approach, I tried using the MinGW distribution from nuwen.net (http://nuwen.net/mingw.html), which conveniently contains boost as it is. But it seems that one can't really link Qt against this MinGW distribution, as I get:



g++ -enable-stdcall-fixup -Wl,-enable-auto-import
-Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl
-Wl,-subsystem,windows -o release\hello_boost_opengl.exe
release/BoostTime.o release/GlWidget.o release/main.o release/MainWindow.o
release/moc_GlWidget.o release/moc_Mainwindow.o -L"c:\usr\Qt\4.3.5\lib"
-lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmain
-lboost_date_time-vc80-mt-1_35 -Lc:\usr\boost\boost_1_35_0\lib -lQtOpenGL4
-lQtGui4 -lQtCore4
release/BoostTime.o:BoostTime.cpp:(.text$_ZN5boost9date_ti me14date_formatterINS_9gregorian4dateENS0_13simple _formatIcEEcE14date_to_stringES3_[boost::date_time::date_formatter<boost::gregorian::date,
boost::date_time::simple_format<char>,
char>::date_to_string(boost::gregorian::date)]+0x1f0): undefined reference
to `boost::gregorian::greg_month::as_short_string() const'
c:\usr\Qt\4.3.5\lib/libqtmain.a(qtmain_win.o):qtmain_win.cpp:(.text+0x 26):
undefined reference to `___gxx_personality_sj0'
c:\usr\Qt\4.3.5\lib/libqtmain.a(qtmain_win.o):qtmain_win.cpp:(.text+0x 39):
undefined reference to `__Unwind_SjLj_Register'
c:\usr\Qt\4.3.5\lib/libqtmain.a(qtmain_win.o):qtmain_win.cpp:(.text+0x 255):
undefined reference to `__Unwind_SjLj_Unregister'
c:\usr\Qt\4.3.5\lib/libqtmain.a(qtmain_win.o):qtmain_win.cpp:(.text+0x 32c):
undefined reference to `__Unwind_SjLj_Resume'
collect2: ld returned 1 exit status



maybe the next approach would be to use the MinGW version that is downloaded by Qt, get MSYS, and compile it manually. I wonder if there's a binary downloadable version of boost that can be used out of the box with Qt and MinGW

All help is appreciated

ChristianEhrlicher
12th June 2008, 15:36
1. You can't mix msvc and mingw c++ libs - so your first approach doesn't work
2. You can't also mix gcc3 and gcc4 which looks like your second problem

So oyu have to compile boost by your own - but why do you want to use msys for this? bjam works on cmd.exe fine too.

akos.maroy
12th June 2008, 15:44
1. You can't mix msvc and mingw c++ libs - so your first approach doesn't work

I wasn't sure about this, so thanks for the clarification


2. You can't also mix gcc3 and gcc4 which looks like your second problem

ah, you mean that Qt itself was compiled againts gcc3, and now I'm trying to use gcc4, and therefore it doesn't work... but then again, I could try compiling Qt with gcc4. hm...


So oyu have to compile boost by your own - but why do you want to use msys for this? bjam works on cmd.exe fine too.

I used an msys prompt because I'm more familiar with UNIX prompts :)

but, actually trying to run bjam from a Windows Command Prompt give me errors (trying with MinGW that is downloaded and installed by Qt itself)



C:\var\install\boost\boost_1_35_0>..\boost-jam-3.1.16-1-ntx86\boost-jam-3.1.16-1
-ntx86\bjam.exe --toolset=gcc --layout=system --with-thread stage
...patience...
...found 680 targets...
...updating 17 targets...
MkDir1 stage
MkDir1 stage\lib
MkDir1 bin.v2
MkDir1 bin.v2\libs
MkDir1 bin.v2\libs\thread
MkDir1 bin.v2\libs\thread\build
MkDir1 bin.v2\libs\thread\build\gcc-3.4.4
MkDir1 bin.v2\libs\thread\build\gcc-3.4.4\release
MkDir1 bin.v2\libs\thread\build\gcc-3.4.4\release\threading-multi
gcc.compile.c++ bin.v2\libs\thread\build\gcc-3.4.4\release\threading-multi\threa
d.o
libs\thread\src\win32\thread.cpp: In function `void boost::<unnamed>::run_thread
_exit_callbacks()':
libs\thread\src\win32\thread.cpp:147: error: `heap_delete' is not a member of `b
oost::detail'
libs\thread\src\win32\thread.cpp:149: error: `heap_delete' is not a member of `b
oost::detail'
libs\thread\src\win32\thread.cpp:159: error: `heap_delete' is not a member of `b
oost::detail'
libs\thread\src\win32\thread.cpp: At global scope:
libs\thread\src\win32\thread.cpp:171: error: no `unsigned int boost::thread::thr
ead_start_function(void*)' member function declared in class `boost::thread'
libs\thread\src\win32\thread.cpp: In member function `void boost::thread::start_
thread()':
libs\thread\src\win32\thread.cpp:194: error: `thread_start_function' undeclared
(first use this function)
libs\thread\src\win32\thread.cpp:194: error: (Each undeclared identifier is repo
rted only once for each function it appears in.)
libs\thread\src\win32\thread.cpp:194: error: 'struct boost::detail::thread_data_
base' has no member named 'id'
libs\thread\src\win32\thread.cpp:194: error: `_beginthreadex' undeclared (first
use this function)
libs\thread\src\win32\thread.cpp:199: error: `intrusive_ptr_add_ref' undeclared
(first use this function)
libs\thread\src\win32\thread.cpp:200: error: `boost::detail::win32' has not been
declared
libs\thread\src\win32\thread.cpp:200: error: `handle' undeclared (first use this
function)
libs\thread\src\win32\thread.cpp: In constructor `boost::<unnamed>::externally_l
aunched_thread::externally_launched_thread()':
libs\thread\src\win32\thread.cpp:215: error: `count' undeclared (first use this
function)
libs\thread\src\win32\thread.cpp:216: error: `interruption_enabled' undeclared (
first use this function)
libs\thread\src\win32\thread.cpp: In function `void boost::<unnamed>::make_exter
nal_thread_data()':

...


(there are more errors, but the forum has a post limit of 10000 characters, so I truncated the output.)

ChristianEhrlicher
12th June 2008, 15:53
The last time I tried the bjam monster (and was then happy that I only use cmake by myself) it worked fine. But it was some time ago...
And yes - you can't link qt4/gcc3 against app/gcc4 and vice versa as the ABI changed there too afaik.