强制CMake寻找x64位库而不是x32 [英] Force CMake to look for x64 bit libraries instead of x32

查看:109
本文介绍了强制CMake寻找x64位库而不是x32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我一直在stackoverflow和其他一些论坛中四处寻找如何强制CMake查找x64库而不是x32,这并没有太大帮助.

So I've been looking around in stackoverflow and some other forums how to force CMake to look for the x64 libraries instead of x32 and it didn't really help much.

当我这样做时:

find_package(Boost
    1.67.0
    COMPONENTS
        atomic
    REQUIRED
)

由于某些原因,CMake会寻找x32库而不是x64库,但找不到它们.我通过在cmake命令中添加此选项来知道这一点:

for some reason CMake looks for the x32 libraries instead of the x64 ones and fails to find them. I know this by adding this option in the cmake command:

-DBoost_DEBUG=ON

哪个显示了这个(它显示的当然比我发布的要多,但是我发布了重要的行):

Which shows me this(It shows of course more than what I posted, but I posted the important lines):

_boost_LIBRARY_SEARCH_DIRS_RELEASE = C:/develop/libraries/boost/1.67.0/x64-vc141/Release/lib
Searching for ATOMIC_LIBRARY_RELEASE: boost_atomic-vc141-mt-x32-1_67;boost_atomic-vc141-mt;boost_atomic-vc140-mt-x32-1_67;boost_atomic-vc140-mt;boost_atomic-mt-x32-1_67;boost_atomic-mt;boost_atomic

但不要寻找这个:

boost_atomic-vc141-mt-x32-1_67

为什么找不到它很明显.
我希望它寻找这个:

Which is obvious why it can't find it.
I want it to look for this:

boost_atomic-vc141-mt-x64-1_67

我想念什么?我想添加一些额外的CMake配置,以使CMake理解我正在使用x64架构的Boost吗?

What am I missing? is there some extra CMake configuration I suppose to add in order to make CMake understand that I'm using boost for x64 architecture?

我什至尝试通过以下方式以手动方式在x64模式下启动Developer Command Prompt for VS 17:

I even tried to start Developer Command Prompt for VS 17 in x64 mode the manual way by calling:

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64

提前感谢您的帮助!

推荐答案

使用CMake生成任何内容时,都应指定一个生成器,除非默认的生成器适合您的需求.看起来在您的情况下,默认设置(无论使用哪种设置)都不适合您,因此您应该像这样提供(对于MSVS 2015):

When you generate anything with CMake you should specify a generator unless the default one suites your needs. Looks like in your case the default one (whatever it is) doesn't work for you so you should provide it like this (for MSVS 2015):

cmake -G "Visual Studio 14 2015 Win64"

请注意,生成器中的体系结构对于搜索非常重要.稍后,您可以使用CMake --build进行构建,但仍必须使用x64编译器生成一些 make 文件.

Note the architecture in the generator it is important for the search. Later you can build it with the CMake --build but you still have to generate some make files which are using x64 compiler.

这篇关于强制CMake寻找x64位库而不是x32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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