CygwinでBoost System libraryを使ったコードをコンパイルするとgeneric_category(), system_category()が見つからないと言われる
現象
a.cpp
#include <boost/system/error_code.hpp> int main() { return 0; }
コンパイルするとgeneric_category(), system_category()が見つからないと言われる
$ g++ -lboost_system a.cpp /tmp/ccGHuN9h.o:a.cpp:(.text+0x28): undefined reference to `boost::system::generic_category()' /tmp/ccGHuN9h.o:a.cpp:(.text+0x32): undefined reference to `boost::system::generic_category()' /tmp/ccGHuN9h.o:a.cpp:(.text+0x3c): undefined reference to `boost::system::system_category()' collect2: error: ld returned 1 exit status
あるはず
$ nm -C /lib/libboost_system.dll.a | grep generic_category 00000000 I _imp___ZN5boost6system16generic_categoryEv 00000000 T boost::system::generic_category() $ nm -C /lib/libboost_system.dll.a | grep system_category 00000000 I _imp___ZN5boost6system15system_categoryEv 00000000 T boost::system::system_category()
解決?
$ g++ a.cpp /lib/libboost_system.dll.a
とやったらコンパイルできた。
よくわからない。
この辺に何か書いてあるかも。
http://stackoverflow.com/questions/5925254/boost-c-static-link-paths-under-cygwin