[CMake] Problem linking boost program_options with Visual Studio 2008

Mario Pezzoni pezzoni.mario at gmail.com
Tue Dec 13 07:57:32 EST 2011


Hi all,

i have a project in c++ that needs program_options library from boost, i
use FindBoost to set include dirs and linking stuff.
Compiling and linking works flawlessly under linux. With the visual studio
project compiling go well but linking fails with this error message:

1>pro_cli.obj : error LNK2001: unresolved external symbol "public: static
unsigned int const
boost::program_options::options_description::m_default_line_length"
(?m_default_line_length at options_description@program_options at boost@@2IB)
1>pro_cli.obj : error LNK2001: unresolved external symbol "class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > boost::program_options::arg" (?arg at program_options
@boost@@3V?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@A)
1>C:\pro\build\cli\Debug\pro_cli.exe : fatal error LNK1120: 2 unresolved
externals

FindBoost under windows find the correct library name and include path. The
CMakeLists.txt follows:

find_package(Boost COMPONENTS program_options REQUIRED)

include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

add_executable(pro_cli pro_cli.cpp)
target_link_libraries(pro_cli
${Boost_LIBRARIES}
)

Do you have any idea why this happen? the same CMakeLists.txt works under
linux so i thinks it is not wrong.

Thank you,
Mario
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111213/41599ffc/attachment-0001.htm>


More information about the CMake mailing list