まず最初に、Windows 7 x64 で Microsoft CL.exe コマンド ライン コンパイラと CMake を使用し、amd64 Visual Studio コマンド ラインで適切に構成します。いくつかの基本的な問題 (たとえば、静的 Boost ではなく共有をリンクしようとした、x64 ターゲットで x86 Boost をリンクしようとしたなど) について説明しましたが、これらの問題を解決したので、 BoostのCMakeフラグに頭を悩ませようとしています。
Boost のさまざまな命名法についてのアイデアがあります (-mt-gd の意味のように)。私の Boost ライブラリはすべて -mt-s です (Release multithreaded.)
-g および -d サフィックスに対応する FindBoost の CMake 変数を知りたいです。
ここに私のCMakeListsがあります:
cmake_minimum_required( VERSION 2.8 )
project( echoserv )
set( APP_NAME Echoserv )
set( MAIN_SOURCE echoserv.cpp )
set( CMAKE_BUILD_TYPE "RELEASE" )
set( Boost_USE_STATIC_RUNTIME ON )
set( Boost_USE_STATIC_LIBS ON )
set( Boost_DEBUG ON )
find_package( Boost COMPONENTS system REQUIRED )
add_executable( ${APP_NAME} ${MAIN_SOURCE} )
include_directories( ${Boost_INCLUDE_DIR} )
link_directories( ${Boost_LIBRARY_DIRS} )
target_link_libraries( ${APP_NAME} ${Boost_LIBRARIES} )
コンパイルしようとすると、次のエラーが発生します。
LINK : fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_53.lib'
これは、Boost ライブラリがすべて「-vc100-mt-s-1_53.lib」の形式であるためです。では、-mt-s ライブラリとリンクし、-mt-gd とのリンクを試みるのをやめるには、どのフラグを使用すればよいでしょうか?
資力:
http://www.boost.org/doc/libs/1_53_0/more/getting_started/windows.html#library-naming http://www.cmake.org/cmake/help/v2.8.8/cmake.html#module %3aFindBoost
明らかに cmake.org リンクが役立つはずですが、変数を正しく設定していると思いますが、まだ mt-gd にリンクしようとしています。
編集: Boost_DEBUG ON を設定した出力は次のとおりです。
(Boost ライブラリは %LIB% にインストールされることに注意してください。)
E:\fastmeta\dev\workspace\personal\learncpp\socks\echoserv>nmake
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:566 ] _boost_TEST_VERSIONS = 1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42;1.41.0;1.41;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
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:568 ] Boost_USE_MULTITHREADED = TRUE
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:570 ] Boost_USE_STATIC_LIBS = ON
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:572 ] Boost_USE_STATIC_RUNTIME = ON
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:574 ] Boost_ADDITIONAL_VERSIONS =
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:576 ] Boost_NO_SYSTEM_PATHS =
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:644 ] Declared as CMake or Environmental Variables:
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:646 ] BOOST_ROOT =
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:648 ] BOOST_INCLUDEDIR =
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:650 ] BOOST_LIBRARYDIR =
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:652 ] _boost_TEST_VERSIONS = 1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42;1.41.0;1.41;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
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:734 ] location of version.hpp: C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/boost/version.hpp
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:754 ] version.hpp reveals boost 1.53.0
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:786 ] guessed _boost_COMPILER = -vc100
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:796 ] _boost_MULTITHREADED = -mt
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:839 ] _boost_RELEASE_ABI_TAG = -s
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:841 ] _boost_DEBUG_ABI_TAG = -sgd
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:884 ] _boost_LIBRARY_SEARCH_DIRS = C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/lib;C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/../lib;C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/stage/lib;C:/boost/lib;C:/boost;C:\Program Files (x86)/boost/boost_1_53_0/lib;C:\Program Files (x86)/boost/boost_1_53/lib;C:\Program Files (x86)/boost/lib;C:\Program Files (x86)/boost;/sw/local/lib
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:962 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-vc100-mt-s-1_53;libboost_system-vc100-mt-s;libboost_system-mt-s-1_53;libboost_system-mt-s;libboost_system
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:994 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-vc100-mt-sgd-1_53;libboost_system-vc100-mt-sgd;libboost_system-mt-sgd-1_53;libboost_system-mt-sgd;libboost_system-mt;libboost_system
-- [ E:/fastmeta/dev/tools/cmake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1108 ] Boost_FOUND = TRUE
-- Boost version: 1.53.0
-- Found the following Boost libraries:
-- system
-- Configuring done
-- Generating done
-- Build files have been written to: E:/fastmeta/dev/workspace/personal/learncpp/socks/echoserv
Linking CXX executable Echoserv.exe
LINK : fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-1_53.lib'
LINK failed. with 2
NMAKE : fatal error U1077: '"E:\fastmeta\dev\tools\cmake\CMake 2.8\bin\cmake.exe
"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.