CMake的发现提高,但NMAKE失败链接(CMake finds boost but nmake

2019-10-18 20:54发布

我有哪里NMAKE不连接升压库cmake的是提供一个问题。 我不知道是什么原因它是这样做的。


cmake_minimum_required(VERSION 2.8)
project(BoostLibTest)
set(Boost_USE_STATIC_LIBS TRUE)
set(Boost_MULTITHREADED TRUE)
set(Boost_DEBUG TRUE)
find_package(Boost COMPONENTS regex)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
add_executable(Example example.cpp)
target_link_libraries(Example ${Boost_LIBRARIES})

CMake的输出:


-- Building for: NMake Makefiles
-- The C compiler identification is MSVC
-- The CXX compiler identification is MSVC
-- Check for CL compiler version
-- Check for CL compiler version - 1500
-- Check if this is a free VC compiler
-- Check if this is a free VC compiler - no
-- Check CL platform
-- Check CL platform - 64 bit
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:362 ] Boost not in cache
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:365 ] _boost_TEST_VERSIONS = 1.40.0;1.40;1.39.0;1.39;1.38.0;1.38;1.37.0;1.37;1.36.1;1.36.0;1.36;1.35.1;1.35.0;1.35;1.34.1;1.34.0;1.34;1.33.1;1.33.0;1.33
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:367 ] Boost_USE_MULTITHREADED = TRUE
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:369 ] Boost_USE_STATIC_LIBS = TRUE
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:428 ] Declared as CMake or Environmental Variables:
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:430 ]   BOOST_ROOT = 
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:432 ]   BOOST_INCLUDEDIR = 
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:434 ]   BOOST_LIBRARYDIR = 
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:436 ] _boost_TEST_VERSIONS = 1.40.0;1.40;1.39.0;1.39;1.38.0;1.38;1.37.0;1.37;1.36.1;1.36.0;1.36;1.35.1;1.35.0;1.35;1.34.1;1.34.0;1.34;1.33.1;1.33.0;1.33
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:485 ] Include debugging info:
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:487 ]   _boost_INCLUDE_SEARCH_DIRS = C:/boost/include;C:/boost;C:\Program Files (x86)/boost/include;C:\Program Files (x86)/boost;/sw/local/include
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:489 ]   _boost_PATH_SUFFIXES = boost-1_40_0;boost_1_40_0;boost-1_40;boost_1_40;boost-1_39_0;boost_1_39_0;boost-1_39;boost_1_39;boost-1_38_0;boost_1_38_0;boost-1_38;boost_1_38;boost-1_37_0;boost_1_37_0;boost-1_37;boost_1_37;boost-1_36_1;boost_1_36_1;boost-1_36_0;boost_1_36_0;boost-1_36;boost_1_36;boost-1_35_1;boost_1_35_1;boost-1_35_0;boost_1_35_0;boost-1_35;boost_1_35;boost-1_34_1;boost_1_34_1;boost-1_34_0;boost_1_34_0;boost-1_34;boost_1_34;boost-1_33_1;boost_1_33_1;boost-1_33_0;boost_1_33_0;boost-1_33;boost_1_33
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:513 ] location of version.hpp: C:/Program Files (x86)/boost/boost_1_40/boost/version.hpp
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:532 ] version.hpp reveals boost 1.40.0
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:623 ] guessed _boost_COMPILER = -vc90
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:633 ] _boost_MULTITHREADED = -mt
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:650 ] _boost_STATIC_TAG = -s
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:652 ] _boost_ABI_TAG = gd
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:685 ] _boost_LIBRARIES_SEARCH_DIRS = C:/Program Files (x86)/boost/boost_1_40/lib;C:/Program Files (x86)/boost/boost_1_40/../lib;C:/boost/lib;C:/boost;C:\Program Files (x86)/boost/boost_1_40_0/lib;C:\Program Files (x86)/boost/boost_1_40/lib;C:\Program Files (x86)/boost/lib;C:\Program Files (x86)/boost;/sw/local/lib
-- [ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:814 ] Boost_FOUND = TRUE
-- Boost version: 1.40.0
-- Found the following Boost libraries:
--   regex
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/blewisjr/Documents/BoostLibTest/bin

NMAKE输出:


Scanning dependencies of target Example
[100%] Building CXX object CMakeFiles/Example.dir/example.cpp.obj
example.cpp
Linking CXX executable Example.exe
example.cpp.obj : error LNK2019: unresolved external symbol "private: class boost::basic_regex > > & __cdecl boost::basic_regex > >::do_assign(char const *,char const *,unsigned int)" (?do_assign@?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@boost@@AEAAAEAV12@PEBD0I@Z) referenced in function "public: class boost::basic_regex > > & __cdecl boost::basic_regex > >::assign(char const *,char const *,unsigned int)" (?assign@?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@boost@@QEAAAEAV12@PEBD0I@Z)

example.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl boost::re_detail::perl_matcher,class std::allocator >,class std::allocator,class std::allocator > > >,struct boost::regex_traits > >::match(void)" (?match@?$perl_matcher@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail@boost@@QEAA_NXZ) referenced in function "bool __cdecl boost::regex_match,class std::allocator >,class std::allocator,class std::allocator > > >,char,struct boost::regex_traits > >(class std::_String_const_iterator,class std::allocator >,class std::_String_const_iterator,class std::allocator >,class boost::match_results,class std::allocator >,class std::allocator,class std::allocator > > > > &,class boost::basic_regex > > const &,enum boost::regex_constants::_match_flags)" (??$regex_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@boost@@YA_NV?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0AEAV?$match_results@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@@0@AEBV?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@0@W4_match_flags@regex_constants@0@@Z)

example.cpp.obj : error LNK2019: unresolved external symbol "private: void __cdecl boost::re_detail::perl_matcher,class std::allocator >,class std::allocator,class std::allocator > > >,struct boost::regex_traits > >::construct_init(class boost::basic_regex > > const &,enum boost::regex_constants::_match_flags)" (?construct_init@?$perl_matcher@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail@boost@@AEAAXAEBV?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@3@W4_match_flags@regex_constants@3@@Z) referenced in function "public: __cdecl boost::re_detail::perl_matcher,class std::allocator >,class std::allocator,class std::allocator > > >,struct boost::regex_traits > >::perl_matcher,class std::allocator >,class std::allocator,class std::allocator > > >,struct boost::regex_traits > >(class std::_String_const_iterator,class std::allocator >,class std::_String_const_iterator,class std::allocator >,class boost::match_results,class std::allocator >,class std::allocator,class std::allocator > > > > &,class boost::basic_regex > > const &,enum boost::regex_constants::_match_flags,class std::_String_const_iterator,class std::allocator >)" (??0?$perl_matcher@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail@boost@@QEAA@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0AEAV?$match_results@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@@2@AEBV?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@2@W4_match_flags@regex_constants@2@0@Z)

Example.exe : fatal error LNK1120: 3 unresolved externals

LINK Pass 1 failed. with 2

失败的链接后NMAKE抛出致命错误U1077

Answer 1:

原来我用目标刺激库只内置了通过切换编译器的x86解决的问题86 64



文章来源: CMake finds boost but nmake fails to link
标签: boost cmake