PDA

View Full Version : Compilation problems with MinGW



nhs_0702
2nd April 2010, 07:52
I successfully compiled Boost with MinGW (GCC 4.4.0 - it came
> installed with the Qt SDK) with all the settings on, so it has
> generated both dynamic and static libraries, debug and release
> versions, multithreaded and non-multithreaded runtimes etc. I tried to
> compile a small program that uses the serialization library


> and tried to link it statically with these libraries (in different
> compilations):



LIBS += "D:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/Boost_Mingw/lib/libboost_filesystem-mgw34-mt.lib"
LIBS += "D:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/Boost_Mingw/lib/libboost_system-mgw34-mt.lib"
LIBS += "D:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/Boost_Mingw/lib/libboost_thread-mgw34-mt.lib"

Each time I compiled, it would always give me linker errors like so:

> undefined reference to `__gxx_personality_sj0'
> undefined reference to `_Unwind_SjLj_Register'
> undefined reference to `_Unwind_SjLj_Unregister'
> undefined reference to `_Unwind_SjLj_Resume'


#include <boost/filesystem/operations.hpp>
#include <iostream>
namespace fs = boost::filesystem;
int main( int argc, char* argv[] )
{
if ( argc != 2 )
{
std::cout << "Usage: file_size path\n";
return 1;
}
std::cout << "sizeof(intmax_t) is " << sizeof(boost::intmax_t) << '\n';
fs::path p( argv[1], fs::native );

if ( !fs::exists( p ) )
{
std::cout << "not found: " << argv[1] << std::endl;
return 1;
}
if ( !fs::is_regular( p ) )
{
std::cout << "not a regular file: " << argv[1] << std::endl;
return 1;
}
std::cout << "size of " << argv[1] << " is " << fs::file_size( p )
<< std::endl;
return 0;
}

toutarrive
2nd April 2010, 08:34
It seems that your Qt was compiled with gcc4.2 (with exceptions type SJLJ model)
According to gcc 4.4.0 :
"- Zero cost exceptions: New exception model Dwarf only has performance
penalty when being thrown. The old model, SJLJ, is no longer
available."

SJLJ has been removed and exceptions generate link errors .
Rebuild Qt with gcc4.4.0 and it should be fine.