c++ - 如何强制 Visual Studio 2010 使用 x64?

标签 c++ visual-studio-2010 platform

每当我在 Visual Studio 2010 中创建一个新项目并且一开始没有设置特定平台(在我的例子中是 x64)时,之后我将无法完全更改它。 所以我用外部库(编译为 x64)设置了所有需要的东西,然后按编译它显然失败了,因为两个平台不匹配。

sfml-graphics-s-d.lib(RenderStates.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

注意到我使用 Build->Configuration-Manager->Active projectplattform->New...->x64 将其更改为 x64。这与我在做任何其他事情之前都会做的事情是一样的,并且它有效,但如果我在之后做它,我会收到链接器错误:

libcpmtd.lib(uncaught.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

*.obj 文件可以在项目之间更改(例如 cout.obj),根据我的理解,Visual Studio 选择 x86 标准库并且在我切换平台后不会改变它的决定。

所以对于这个问题:我如何强制 VS 使用新指定的 x64 平台 - 也适用于标准库?

注意:创建新的配置设置会自动将目标机器的链接器设置更改为:MachineX64 (/MACHINE:X64)

注意:不确定它是否相关,但我正在静态链接运行时库Multithreaded-Debug (/MTd)

最佳答案

如果有人遇到和我一样的问题,他可以在 the MSDN 'forum' 找到讨论和解决方案。 .

OK, I found it, LibraryPath corresponds to Library Directories property in VC++ Directories project property page. That explains what happened, that value is usually inherited so it changes automatically when you create add x64. But since you modified that value it is now local to the project and it simply gets copied when add x64... with all those x86 specific dirs.

I suppose it's simpler and safer to just add that lib dir in Linker\General\Additional Library Directories

关于c++ - 如何强制 Visual Studio 2010 使用 x64?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10849420/

相关文章:

ASP.NET Visual Studio 不捕获更改 - 从临时文件编译

c# - 转义左括号 C# 正则表达式

c++ - 从函数返回的左值引用实际上是右值(从调用者的角度来看)吗?

c++ - 如何为我的自定义 C++ 类实现复制构造函数

c# - 如何在此上下文中调用接口(interface)方法?

c# - x86 DLL 有效但 x64 DLL 无效

c# - Windows应用程序中平台和目标平台的区别

php - 如何创建平台或可移植代码来节省您的时间?

c++ - 与不同架构上的数据对齐相关的问题是什么?

c++ - 硬件是否将多个代码操作合并为一个物理 CPU 操作?