PDA

View Full Version : Build QTCreator boost::filesystem



nhs_0702
30th March 2010, 11:34
i read lib boost in http://www.boost.org/doc/libs/1_42_0.../file_size.cpp then build on QTCreator but it error,can you help Me debug source ?




#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;
}



**/boost_1_42_0/boost/system/error_code.hpp:208: undefined reference to `boost::system::get_system_category()'**



my source code
http://www.mediafire.com/?inzzmlwwm4w

wysota
30th March 2010, 20:30
Did you link your application against boost library?

nhs_0702
31st March 2010, 08:20
my source http://www.mediafire.com/?inzzmlwwm4w
i link source into boost source (not binary),can you help me ?

wysota
31st March 2010, 09:06
Obviously you didn't link the body of the method your compiler complains about.

nhs_0702
1st April 2010, 07:37
can you config .pro file ?


#-------------------------------------------------
#
# Project created by QtCreator 2010-03-30T04:29:20
#
#-------------------------------------------------

QT -= gui

TARGET = QTBoost_Simple
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += D:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0

i dont link .lib , .a ( library binary ),but i think it loss link,can you help me ?

nhs_0702
1st April 2010, 07:46
if i write in .pro is

#-------------------------------------------------
#
# Project created by QtCreator 2010-03-30T04:29:20
#
#-------------------------------------------------

QT -= gui

TARGET = QTBoost_Simple
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += D:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0
LIBS += C:/Users/BotNetVN/Desktop/QTBoost_Simple/libboost_filesystem-vc90-mt-1_42.lib C:/Users/BotNetVN/Desktop/QTBoost_Simple/libboost_system-vc90-mt-1_42.lib

then Qtcreator error



Running build steps for project QTBoost_Simple...
Starting: i:/programfiles/qt/bin/qmake.exe C:/Users/BotNetVN/Desktop/QTBoost_Simple/QTBoost_Simple.pro -spec win32-g++ -r
Exited with code 0.
Starting: I:/ProgramFiles/mingw/bin/mingw32-make.exe -w
mingw32-make: Entering directory `C:/Users/BotNetVN/Desktop/QTBoost_Simple'
I:/ProgramFiles/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Users/BotNetVN/Desktop/QTBoost_Simple'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\QTBoost_Simple.exe debug/main.o -L"i:\ProgramFiles\qt\lib" C:/Users/BotNetVN/Desktop/QTBoost_Simple/libboost_filesystem-vc90-mt-1_42.lib C:/Users/BotNetVN/Desktop/QTBoost_Simple/libboost_system-vc90-mt-1_42.lib -lQtCored4
mingw32-make[1]: Leaving directory `C:/Users/BotNetVN/Desktop/QTBoost_Simple'
mingw32-make: Leaving directory `C:/Users/BotNetVN/Desktop/QTBoost_Simple'
debug/main.o: In function `main':
C:\Users\BotNetVN\Desktop\QTBoost_Simple/main.cpp:12: undefined reference to `boost::filesystem::native(std::string const&)'
debug/main.o: In function `_static_initialization_and_destruction_0':
d:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0/boost/system/error_code.hpp:208: undefined reference to `boost::system::get_system_category()'
d:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0/boost/system/error_code.hpp:209: undefined reference to `boost::system::get_generic_category()'
d:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0/boost/system/error_code.hpp:214: undefined reference to `boost::system::get_generic_category()'
d:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0/boost/system/error_code.hpp:215: undefined reference to `boost::system::get_generic_category()'
d:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0/boost/system/error_code.hpp:216: undefined reference to `boost::system::get_system_category()'
debug/main.o: In function `error_code':
d:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0/boost/system/error_code.hpp:315: undefined reference to `boost::system::get_system_category()'
debug/main.o:d:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0/boost/filesystem/operations.hpp:293: undefined reference to `boost::filesystem::detail::status_api(std::string const&, boost::system::error_code&)'
debug/main.o:d:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0/boost/filesystem/operations.hpp:324: undefined reference to `boost::filesystem::detail::status_api(std::string const&, boost::system::error_code&)'
debug/main.o:d:/CD_LAP_TRINH/cach_su_dung_thu_vien_boost/boost_1_42_0/boost/filesystem/operations.hpp:390: undefined reference to `boost::filesystem::detail::file_size_api(std::str ing const&)'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\QTBoost_Simple.exe] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project QTBoost_Simple
When executing build step 'Make'



download
libboost_filesystem-vc90-mt-1_42.lib
libboost_system-vc90-mt-1_42.lib
http://www.mediafire.com/?nzmyzqyd1m5


and My source code: http://www.mediafire.com/?2gzoyloyqt5