2012-04-09 8 views
0

私は私の共有ライブラリにprogram_optionsをリンクしています:私は理由abstract_variables_mapの未定義参照のライブラリをロードすることはできません未定義の参照ブースト:: program_options :: abstract_variables_map ::演算子[]

g++ -L/path_to_static_boost_libs -shared -o "test.so" ./test.o -lboost_program_options 

::演算子[]:

0009b9f8 W int const& boost::program_options::variable_value::as<int>() const 
     U boost::program_options::abstract_variables_map::operator[](std::string const&) const 
0009b55e W boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_any_cast> >::clone() const 

program_optionsライブラリを静的にリンクされ、未定義の参照を取得していないと私は別のプログラム(いない共有ライブラリ)を構築しようとしました。

なぜ私は共有ライブラリをリンクしているときに未定義参照を取得しますか?

+2

'-lboost_system'も追加してみてください。 –

+0

-lboost_systemは役に立ちません。 – Raman

+0

'test.so'に入るコードを投稿して、あなたが見ている振る舞いを再現できるようにしてください。 –

答えて

1

ステップ1:を探してください。未解決シンボルの名前(既にdlerror()エラーメッセージに表示されているはずです)。

ステップ2:を見つけるブーストライブラリのは、そのシンボルの定義を提供します。

nm -A /path_to_static_boost_libs/*.a | grep <mangled-symbol-name> 

ステップ3:test.soのリンク行にそのライブラリを追加します。

ステップ4:利益。