Benim CMakeFiles.txt şuna benzer:Bağlama artırmak kütüphane
cmake_minimum_required (VERSION 2.6)
# Set warnings on and enable debugging
SET(CMAKE_C_FLAGS "-Wall -q")
include(FindBoost)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.57.0 COMPONENTS system filesystem REQUIRED)
if(Boost_FOUND)
message(STATUS "Boost found!")
include_directories(${Boost_INCLUDE_DIRS})
add_executable(foo main.cpp)
# Needed for asio
if(WIN32)
target_link_libraries(foo wsock32 ws2_32)
endif()
target_link_libraries(foo ${Boost_LIBRARIES})
endif()
Ben projeyi işlemek Visual Studio 2013 64 bit:
cmake -G "Visual Studio 12 Win64" -DBOOST_LIBRARYDIR=D:\Development\Tools\boost_1_57_0\stage\x64\lib ..\KServer
çıktısı:
-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler using: Visual Studio 12 2013 Win64
-- Check for working C compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 12 2013 Win64
-- Check for working CXX compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.57.0
-- Boost version: 1.57.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- Boost found!
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Development/Private/C++/KServerProject
Bu hepsi iyi ve iyi.
Sorun burada başlar: Kullandığım benim cmake dosyasını değiştirdiğinizde
:
error LNK1104: cannot open file 'libboost_filesystem-vc120-mt-gd-1_57.lib' D:\Development\Private\C++\KServerProject\src\LINK foo
Kontrol Edilmesi:
set(Boost_USE_STATIC_LIBS OFF)
Sonra Visual Studio zaman binayı aşağıdaki hatayı alıyorum Stüdyoda Property Pages
kütüphanesi bağımlılık olarak eklenmiştir:
elle ince oluşturur D:\Development\Tools\boost_1_57_0\stage\x64\lib
Additional Library Directories
klasörü ekleme.
Dinamik libs kullanarak proje oluşturmak için nasıl alabilirim?
Cmake ile kullandığım destek sistemimde yapının kökünde 3 klasör var. kurmak, dahil etmek ve lib. Her ne kadar kaynak yapıyorum. – drescherjm
Aşağıdaki yapı tipini bjam '--build-type = complete stage install' ile kullanıyorum – drescherjm
Bu bir sorun değil. Tamamladım. Cmake kullanarak oluştururken dinamik bağlantı ile çalışmak için destek kullanarak projeye ihtiyacım var. – Asken