
Hi, I am on the following platform: Linux 2.6.0-test5 #11 Wed Sep 10 20:28:31 CEST 2003 i686 unknown Reading specs from /usr/lib/gcc-lib/i386-slackware-linux/3.2.2/specs Configured with: ../gcc-3.2.2/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i386-slackware-linux --host=i386-slackware-linux Thread model: posix gcc version 3.2.2 Boost version 1.30.2 compiled with: bjam "-sTOOLS=gcc" I have a question regarding the following boost::filesystem use case: try { for(fs::directory_iterator dir_itr(full_path); dir_itr != end_iter; ++dir_itr ) { // use dir_itr } } catch(const std::exception &ex) { std::cout << ex.what() << std::endl; } In case of full_path pointed to the directory without read permissions the corresponding exception is thrown and catched in the catch block. My problem is that if I compile my application with -fPIC option, I am unable to catch the exception anymore and the program is simply aborted. I need to use -fPIC because of other library which has own build system and if I follow suggested guidlines for Makefile, I get -fPIC automatically. I would verry appreciate if somebody could tell me are there any ways to make the code mentioned above work when it is compiled with -fPIC? Should I recompile boost with -fPIC? If yes, what is the right place to set this parameter? BTW how it is supposed to write a shared library which includes boost code? As I understand, than my code must be compiled with -fPIC... Thanks, Andrey. P.S. Here is example I am using and the makefile: // ttt.cpp #include <iostream> #include <boost/filesystem/operations.hpp> #include <boost/filesystem/path.hpp> namespace fs = boost::filesystem; int main(int argc, char **argv) { try { fs::path full_path = fs::system_complete(fs::path(argv[1], fs::native)); fs::directory_iterator end_iter; for(fs::directory_iterator dir_itr(full_path); dir_itr != end_iter; ++dir_itr ) { std::cout << dir_itr->leaf() << std::endl; } } catch(const std::exception &ex) { std::cout << ex.what() << std::endl; } return 0; } Makefile: CPPFLAGS := -I/usr/local/src/boost LDFLAGS := -L/usr/local/src/boost/libs/filesystem/build/bin/libboost_filesystem.a/gcc/debug/runtime-link-dynamic/ LIBS := $(LIBS) -lboost_filesystem ttt: ttt.cpp c++ $(CPPFLAGS) -g -ftemplate-depth-128 -fPIC -Wall $(LDFLAGS) -o $@ ttt.cpp $(LIBS) __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
participants (1)
-
Andrey Nechypurenko