问题联系起来,以提高库的CMake生成的项目文件MSVC9 [英] Problem linking to boost library with CMake generated project file for MSVC9

查看:178
本文介绍了问题联系起来,以提高库的CMake生成的项目文件MSVC9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过创建一个的CMake项目MSVC9.0文件,构建具有升压库的应用程序。

I'm trying to build an application with boost library by creating a MSVC9.0 project files with CMake.

我收到以下错误:
错误3致命错误LNK1104:无法打开文件'libboost_system-vc90-MT-GD-1_44.lib

I get the following error: Error 3 fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-gd-1_44.lib'

下面是CMake的配置。

Here is the CMake configuration

cmake_minimum_required(VERSION 2.8)
PROJECT( TestProject)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
set(BOOST_ROOT "D:/boost_1_44_0")
set(Boost_USE_MULTITHREADED ON)
FIND_PACKAGE( Boost 1.44.0 REQUIRED unit_test_framework system)

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${BOOST_ROOT})
LINK_DIRECTORIES(${LINK_DIRECTORIES} "D:/boost_1_44_0/stage/lib")


SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
SET(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
ADD_EXECUTABLE(testapp
main.cpp)

TARGET_LINK_LIBRARIES(testapp
${Boost_SYSTEM_LIBRARY}
)

SET_TARGET_PROPERTIES( testapp PROPERTIES DEBUG_POSTFIX "d" )

我已经建立提升静态和共享(调试和发布)与下列选项。

I have built boost for static and shared (debug and release) with following options.

bjam toolset=msvc  variant=debug   link=shared runtime-link=shared threading=multi --build-type=complete stage
bjam toolset=msvc  variant=release link=shared runtime-link=shared threading=multi --build-type=complete stage
bjam toolset=msvc  variant=debug   link=static runtime-link=static threading=multi --build-type=complete stage
bjam toolset=msvc  variant=release link=static runtime-link=static threading=multi --build-type=complete stage

我不知道什么,我缺少的配置。有什么建议么?
谢谢你。

I'm not sure what I'm missing in the configuration. Any suggestions? Thanks.

推荐答案

首先,你检查,如果'libboost_system-vc90-MT-GD-1_44.lib真的在你的存在阶段-dir的D:/ boost_1_44_0 /台/ lib目录?

First of all, did you check if "'libboost_system-vc90-mt-gd-1_44.lib" really exists in your stage-dir "D:/boost_1_44_0/stage/lib"?

二:我曾经有升压和CMake的的find_package(升压)最常见的问题是与自动联的干扰。你可以通过添加一个定义你的编译标志禁用

Second: the most common problem I used to have with Boost and CMake's find_package( Boost) was interference with the auto-linking. You could disable it by adding a definition to your compile flags

add_definitions( -DBOOST_ALL_NO_LIB )

不过,那么你可能需要指定,如果你要链接到的动态或静态版

but then you probably will need to specify if you want to link to the dynamic or static version

set( Boost_USE_STATIC_LIBS ON ) # or Off, depending on what you want
find_package( Boost 1.44.0 REQUIRED unit_test_framework system)

当然,你总是可以检查生成视觉工作室文件,看看哪些链接库实际上是添加到您的项目。

Of course, you could always check the generated visual studio files to see which link-libraries are actually added to your project.

这篇关于问题联系起来,以提高库的CMake生成的项目文件MSVC9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆