LoginSignup
0
0

More than 1 year has passed since last update.

g++のboostで-lboost_program_optionsオプションつけたのにundefined reference

Posted at

問題

$ sudo apt-get install libboost-all-dev

をして

$ g++ -lboost_program_options -lboost_filesystem  main.cpp

を実行すると

main.cpp:(.text+0x48): undefined reference to `boost::program_options::operator<<(std::ostream&, boost::program_options::options_description const&)'

のようなエラーがずらっと出てくる

解決

-lboost_program_options -lboost_filesystemは必ず最後に指定する必要がある.
つまり

$ g++ main.cpp -lboost_program_options -lboost_filesystem 

の形式で実行する必要がある.

参考文献

C++ Boostによるコマンドライン引数処理

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0