RTT 1.10.0 MinGW build problems

Hi Peter,

I've downloaded the Orocos RTT 1.10.0 release to build it on a Windows XP machine with MinGW compiler. There are some issues I stumbled across during the build process that may be interesting for you.

First I tried to build Orocos + Tests with MinGW GCC 3.4 (the MinGW installation that is included in Qt 4.5 distribution) + Boost 1.39. The build failed because windows.h is not included for MinGW and struct timespec is unknown in src/os/win32/fosi.h. The attached patch fixes these two issues.

After I applied this patch the liborocos-rtt-win32.dll was built successfully but test case build failed. The compiler reported the following error on building core-test.exe and program-test.exe:

D:\CodingXP\Sources & Projects\orocos-rtt-1.10.0-svn\tests\property_test.cpp:423: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.mingw.org/bugs.shtml> for instructions. mingw32-make[2]: *** [tests/CMakeFiles/core-test.dir/property_test.cpp.obj] Error 1 mingw32-make[1]: *** [tests/CMakeFiles/core-test.dir/all] Error 2 mingw32-make: *** [all] Error 2

I then tried to build again with Boost 1.40 but the error still occures. I could not successfully build all test cases with MinGW GCC 3.4.

After this try I replaced my MinGW installation with the installation from http://www.tdragon.net/recentgcc/. This MinGW installation comes with an actual GCC 4.4.0 compiler. I rebuilded the Boost 1.40 libraries with GCC 4.4.0 compiler without any trouble. Then I ran CMake again on Orocos to create a new an clean build tree. Then I tried to build Orocos + tests with MinGW with GCC 4.4.0 and Boost 1.40.

The build failed because of a conflict with usleep that is already provided by MinGW:

D:\CodingXP\Sources & Projects\orocos-rtt-1.10.0-svn\src\os/win32/fosi.h:69: error: declaration of C function 'void usleep(long int)' conflicts with c:\codingxp\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../../include/unistd.h:36: error: previous declaration 'int usleep(useconds_t)' here mingw32-make[3]: *** [src/CMakeFiles/orocos-rtt-dynamic_win32.dir/Activity.cpp.obj] Error 1 mingw32-make[2]: *** [src/CMakeFiles/orocos-rtt-dynamic_win32.dir/all] Error 2 mingw32-make[1]: *** [tests/CMakeFiles/check.dir/rule] Error 2 mingw32-make: *** [check] Error 2

The attached patch fixes this issue. After I applied this patch I restarted the build. Now the compiler sucessfully compiled all files but the final linker step of liborocos-rtt-win32.dll failed wth the following error message:

Linking CXX shared library liborocos-rtt-win32.dll Creating library file: liborocos-rtt-win32.dll.a Cannot export _ZN12_GLOBAL__N_115GraphEdgeCopierC1ERKN5boost14adjacency_listINS1_4vecSENS1_5listSENS1_9directedSENS1_8propertyIN3RTT16vertex_command_tENS7_10VertexNodeENS6_INS7_13vertex_exec_tEiNS6_INS1_14verte x_index_tEiNS1_11no_propertyEEEEEEENS6_I16edge_condition_tNS7_13EdgeConditionENS6_INS1_12edge_index_tEiSC_EEEESC_S4_EERSL_RSt3mapIPKNS7_14DataSourceBaseEPSQ_St4lessISS_ESaISt4pairIKSS_ST_EEE: symbol not found Cannot export _ZN12_GLOBAL__N_115GraphEdgeCopierclERKN5boost6detail14edge_desc_implINS1_12directed_tagEPvEES8_: symbol not found Cannot export _ZN12_GLOBAL__N_117GraphVertexCopierC1ERKN5boost14adjacency_listINS1_4vecSENS1_5listSENS1_9directedSENS1_8propertyIN3RTT16vertex_command_tENS7_10VertexNodeENS6_INS7_13vertex_exec_tEiNS6_INS1_14ver tex_index_tEiNS1_11no_propertyEEEEEEENS6_I16edge_condition_tNS7_13EdgeConditionENS6_INS1_12edge_index_tEiSC_EEEESC_S4_EERSL_RSt3mapIPKNS7_14DataSourceBaseEPSQ_St4lessISS_ESaISt4pairIKSS_ST_EEE: symbol not found

Cannot export _ZN12_GLOBAL__N_117GraphVertexCopierclERKPvRS1_: symbol not found Cannot export _ZNK3RTT18TypeInfoRepository11getTypeInfoIN12_GLOBAL__N_13BarEEEPNS_8TypeInfoEv: symbol not found collect2: ld returned 1 exit status mingw32-make[3]: *** [src/liborocos-rtt-win32.dll] Error 1 mingw32-make[2]: *** [src/CMakeFiles/orocos-rtt-dynamic_win32.dir/all] Error 2 mingw32-make[1]: *** [tests/CMakeFiles/check.dir/rule] Error 2 mingw32-make: *** [check] Error 2

The linker complains that it cannot export GraphVertexCopier and GraphEdgeCopier functions and getTypeInfo() function of class TypeInfoRepository. I checked the first two classes that are defined in GraphCopier.hpp. Both classes are "header files only" and do not have a cpp file. So it seems that the GCC 4.4.0 compiler has a problem to detect that the functions are all implemented in the header file. Because these two classes are implemented completely in the header files it would be save here to remove RTT_API. I did this and solved two of these three linker issues.

For the TypeInfoRepository class that is defined in Types.hpp and implemented in Types.cpp I could not find a solution. The problem in this class is the template methode getTypeInfo(). This method is completely implemented in the header file and cannot be compiled into the DLL because the types of this method are unknown at compile time. But the MinGW GCC 4.4.0 cannot handle this properly. Removing RTT_API here may cause trouble, because parts of the class are impemented in the cpp file and should be exported from the DLL. Obviously GCC 3.4 and GCC 4.4.0 behave differently here.

But I found a work around or maybe a solution. Because MinGW GCC supports auto import feature for DLLs it is not necessary (at least for Orocos) to use __declspec(dllexport) or __declspec(dllimport). I changed the file rtt-config.h.in to make RTT_API and RTT_EXPORT empty statements (see attached patch) for MinGW builds.

Regarding the test cases: All tests except the parser-test.exe passt sucessfully. parser-test.exe crashes always - I need to investigate further here.

Sorry that I post this after the RTT 1.10.0 release but I had no time to test this earlier.

Regards, Uwe

AttachmentSize
orocos-mingw.patch2.18 KB

RTT 1.10.0 MinGW build problems

Hi Uwe,

Thanks for this precise report, more comments below...

On Sun, Sep 20, 2009 at 18:41, <uwe_kindler [..] ...> wrote:
> Hi Peter,
>
> I've downloaded the Orocos RTT 1.10.0 release to build it on a Windows
> XP machine with MinGW compiler. There are some issues I stumbled across
> during the build process that may be interesting for you.
>
> First I tried to build Orocos + Tests with MinGW GCC 3.4 (the MinGW
> installation that is included in Qt 4.5 distribution) + Boost 1.39. The
> build failed because windows.h is not included for MinGW and struct timespec
> is unknown in src/os/win32/fosi.h. The attached patch fixes these two
> issues.

Ok.

>
> After I applied this patch the liborocos-rtt-win32.dll was built
> successfully but test case build failed. The compiler reported the following
> error on building core-test.exe and program-test.exe:
>
> D:\CodingXP\Sources &
> Projects\orocos-rtt-1.10.0-svn\tests\property_test.cpp:423: internal
> compiler error: Segmentation fault
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL:http://www.mingw.org/bugs.shtml> for instructions.
> mingw32-make[2]: *** [tests/CMakeFiles/core-test.dir/property_test.cpp.obj]
> Error 1
> mingw32-make[1]: *** [tests/CMakeFiles/core-test.dir/all] Error 2
> mingw32-make: *** [all] Error 2

The only way (I know) to find out which line of code causes this, is
by #if 0 .. #endif constructs and binary-search your way into the
file. Sometimes it helps splitting up a file in two pieces and have
them compiled separately.

Last time I checked, gcc 3.4 on Linux didn't have problems with our code.

>
> I then tried to build again with Boost 1.40 but the error still occures. I
> could not successfully build all test cases with MinGW GCC 3.4.
>
> After this try I replaced my MinGW installation with the installation from
> http://www.tdragon.net/recentgcc/. This MinGW installation comes with an
> actual GCC 4.4.0 compiler. I rebuilded the Boost 1.40 libraries with GCC
> 4.4.0 compiler without any trouble. Then I ran CMake again on Orocos to
> create a new an clean build tree. Then I tried to build Orocos + tests with
> MinGW with GCC 4.4.0 and Boost 1.40.
>
> The build failed because of a conflict with usleep that is already provided
> by MinGW:
>
> D:\CodingXP\Sources & Projects\orocos-rtt-1.10.0-svn\src\os/win32/fosi.h:69:
> error: declaration of C function 'void usleep(long int)' conflicts with
> c:\codingxp\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../../include/unistd.h:36:
> error: previous declaration 'int usleep(useconds_t)' here
> mingw32-make[3]: ***
> [src/CMakeFiles/orocos-rtt-dynamic_win32.dir/Activity.cpp.obj] Error 1
> mingw32-make[2]: *** [src/CMakeFiles/orocos-rtt-dynamic_win32.dir/all] Error
> 2
> mingw32-make[1]: *** [tests/CMakeFiles/check.dir/rule] Error 2
> mingw32-make: *** [check] Error 2

There are two issues here: you fixed the double definition, but I
planned to also let usleep return an int instead of void ( on native
windows ).

...

>
> The linker complains that it cannot export GraphVertexCopier and
> GraphEdgeCopier functions and getTypeInfo() function of class
> TypeInfoRepository. I checked the first two classes that are defined in
> GraphCopier.hpp. Both classes are "header files only" and do not have a cpp
> file. So it seems that the GCC 4.4.0 compiler has a problem to detect that
> the functions are all implemented in the header file. Because these two
> classes are implemented completely in the header files it would be save here
> to remove RTT_API. I did this and solved two of these three linker issues.

The reason they are header only is that they are only included by a
single RTT .cpp file. So the RTT_API can/must indeed go.

>
> For the TypeInfoRepository class that is defined in Types.hpp and
> implemented in Types.cpp I could not find a solution. The problem in this
> class is the template methode getTypeInfo(). This method is completely
> implemented in the header file and cannot be compiled into the DLL because
> the types of this method are unknown at compile time. But the MinGW GCC
> 4.4.0 cannot handle this properly. Removing RTT_API here may cause trouble,
> because parts of the class are impemented in the cpp file and should be
> exported from the DLL. Obviously GCC 3.4 and GCC 4.4.0 behave differently
> here.

The work around for this case is to remove the RTT_API declaration
from the class and apply it to the individual member functions (except
the templated ones).

>
> But I found a work around or maybe a solution. Because MinGW GCC supports
> auto import feature for DLLs it is not necessary (at least for Orocos) to
> use __declspec(dllexport) or __declspec(dllimport). I changed the file
> rtt-config.h.in to make RTT_API and RTT_EXPORT empty statements (see
> attached patch) for MinGW builds.

I don't have enough experiences with the declared vs auto import
feature to know which is best. It's maybe better to add
-DORO_(NO_)AUTO_IMPORT such that the user can switch between both
modes.

>
> Regarding the test cases: All tests except the parser-test.exe passt
> sucessfully. parser-test.exe crashes always - I need to investigate further
> here.

I'm novice here... do you just use the mingw version of gdb to debug
such cases or another tool ?

>
> Sorry that I post this after the RTT 1.10.0 release but I had no time to
> test this earlier.

There's always a .1 release :-).

Thanks for the patch & feedback,

Peter