Im trying to run sample app from wxFreeChart library. After compilation on linking there is an error:
我正在尝试运行wxFreeChart库的示例应用程序。编译链接后出现错误:
wxcode_msw28d_freechart.lib(wxfreechart_lib_xydataset.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
I tried to switch linker option\advanced\target machine to MachineX64 but it doesnt work.
我试着把linker option\advanced\target machine改为MachineX64,但是没有效果。
Im using visual studio 2008, any suggestion ?
我在使用visual studio 2008,有什么建议吗?
thanks for help
谢谢你的帮助
12 个解决方案
#1
32
The error is explicit, you are trying to link libraries that were compiled with different CPU targets. An executable image can only contain pure x86 (32-bit) or pure x64 (64-bit) code. Mixing is not possible.
错误是显式的,您正在尝试链接使用不同CPU目标编译的库。可执行映像只能包含纯x86(32位)或纯x64位(64位)代码。混合是不可能的。
You change the target CPU by creating a new configuration for the project, only changing the linker setting isn't enough. Build + Configuration Manager, Active solution platform combo on upper right, choose New and select x64. That creates a new configuration with several modified project settings, most importantly the compiler that will be used.
您通过为项目创建一个新的配置来更改目标CPU,仅更改链接器设置是不够的。构建+配置管理器,活跃的解决方案平台组合在右上角,选择New并选择x64。这样就创建了一个带有几个修改过的项目设置的新配置,最重要的是将使用的编译器。
Beware that prior to VS2010, the 64-bit compilers are not installed by default. If you don't see x64 in the platform combo then you'll need to re-run setup.exe and turn on the option to install the 64-bit compilers. Then also re-run any service pack installer you may have applied.
注意,在VS2010之前,64位编译器不是默认安装的。如果您在平台组合中没有看到x64,那么您需要重新运行安装程序。执行并打开安装64位编译器的选项。然后重新运行您可能已经应用的任何服务包安装程序。
A possible approach with less pain points is to use the 32-bit version of the library.
一种更少痛苦点的方法是使用32位版本的库。
#2
17
I bumped into this too and found a solution.
我也碰到了这个问题,找到了解决办法。
First on how I got into this problem. I have a project which builds in x86. Then I use the Configuration Manager to add x64, and I hit this problem.
首先谈谈我是如何陷入这个问题的。我有一个在x86上构建的项目。然后我使用Configuration Manager添加x64,然后遇到这个问题。
By looking at BuildLog.htm carefully, I see both of these listed as linker options: /MACHINE:X64
/machine:X86
通过观察BuildLog。仔细地看一下htm,我发现这两种方法都被列为链接器选项:/MACHINE:X64 /MACHINE: X86
I can't find any where in the Property Pages dialog where I can change this, so I open up the .vcproj file and look for the appropriate line and change it to: AdditionalOptions=" /STACK:10000000 /machine:x64 /debug"
在属性页对话框中,我找不到可以更改的地方,所以我打开.vcproj文件,查找适当的行并将其更改为:AdditionalOptions=" /STACK:10000000 /machine:x64 /debug"
and it works.
和它的工作原理。
#3
5
Go to project properties-> configuration properties -> Librarian Set Target Machine to MachineX64 (/MACHINE:X64)
转到项目属性—>配置属性—> library将目标机设置为MachineX64 (/ Machine:X64)
#4
5
In my case it appears it was because I had "copied settings" from a 32-bit to a new configuration (64 bit) and it hadn't updated the libraries. Odd.
在我的例子中,这似乎是因为我将设置从32位“复制”到新的配置(64位),而它没有更新库。奇数。
1>MSVCRTD.lib(ti_inst.obj) : fatal error LNK1112: module machine type ‘X86’ conflicts with target machine type ‘x64’
1>MSVCRTD.lib(ti_inst.obj):致命错误LNK1112:模块机类型‘X86’与目标机类型‘x64’冲突
this meant “your properties -> VC++ Directories -> Library Directories” is pointing to a directory that has 32 bit libs built in it. Fix somehow!
这意味着“您的属性-> vc++目录->库目录”指向一个包含32位libs的目录。修复不知怎么的!
In my case http://social.msdn.microsoft.com/Forums/ar/vcgeneral/thread/c747cd6f-32be-4159-b9d3-d2e33d2bab55
在我的例子中http://social.msdn.microsoft.com/forums/ar/vcgeneral/thread/c747cd6f - 32 - 4159 - b9d3 d2e33d2bab55
ref: http://betterlogic.com/roger/2012/02/visual-studio-2010-express-64-bit-woe
裁判:http://betterlogic.com/roger/2012/02/visual工作室- 2010表达- 64位的有祸了
#5
2
Since the problem is due to the difference in compilation and target machine specifications (x86 & x64) Follow the steps below:
由于问题是由于编译和目标机器规范(x86 & x64)的差异导致的,下面的步骤如下:
- Open the C++ project that you want to configure.
- 打开要配置的c++项目。
- Choose the Configuration Manager button to open the Configuration Manager dialog box.
- 选择Configuration Manager按钮以打开Configuration Manager对话框。
- In the Active Solution Platform drop-down list, select the option to open the New Solution Platform dialog box.
- 在活动解决方案平台下拉列表中,选择打开新解决方案平台对话框的选项。
- In the Type or select the new platform drop-down list, select a 64-bit platform.
- 在类型或选择新平台下拉列表中,选择一个64位平台。
This solved my problem.
这解决了我的问题。
#6
1
Try changing every occurence of .\Release into .\x64\Release in the x64 properties. At least this worked for me...
试着在x64属性中把每一次发生的。\版本改为。\x64\版本。至少对我来说是这样的……
#7
0
I know this is a bit old, but I thought I would provide another tip. In my situation, I inherited this application that I had to maintain. The VS2008 project came with the same string in C/C++->OutputFIles->"ObjectFIleName" and "Program Database File Name" (for both platforms Win32 and x64). So when I built Win32 platform, it built fine, but when I tried to build x64, I got the error:
我知道这有点旧了,但我想我可以提供另一个提示。在我的情况下,我继承了这个必须维护的应用程序。VS2008项目在C/C+ ->输出文件->“ObjectFIleName”和“Program Database文件名”(用于Win32和x64平台)中使用了相同的字符串。因此,当我构建Win32平台时,它构建得很好,但是当我尝试构建x64时,我得到了一个错误:
\Debug64\Objects\common.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
\ Debug64 \ \常见的对象。obj:致命错误LNK1112:模块机类型‘X86’与目标机类型‘x64’冲突
Obviously, both patforms were storing common.obj at the same location, so when I tried to build x64, the linker took the existing object file, which was x86.
显然,这两种模式都是通用的。obj位于同一个位置,因此当我尝试构建x64时,链接器获取了现有的x86对象文件。
To fix I just replaced the existing string with the macro "$(IntDir)\" for x64 (no quotes), and made sure that the macro resolved to the correct path, as in the rest of the projects. That solved my problem.
为了修复,我用x64(没有引号)的“$(IntDir)\”宏替换了现有的字符串,并确保宏解析为正确的路径,如其他项目中所示。这解决了我的问题。
#8
0
An update to i00g's and Thomas' answers, this time for VS2012 (some names have changed). After copying x86 settings over into an x64 target with the configuration manager, you'll have the problem for the same reason as was the case earlier (lib targets aren't correct in the x64 config). Open your .vcxproj (text editor) and replace MachineX86 with MachineX64 where appropriate. (I still haven't found where this is on the property sheets....) This only seems to be necessary with static libs.
更新i00g和Thomas的答案,这次是VS2012(有些名字已经改变)。在使用configuration manager将x86设置复制到x64目标之后,您将遇到与前面情况相同的问题(在x64配置中,lib目标不正确)。打开.vcxproj(文本编辑器),在适当的情况下将MachineX86替换为MachineX64。(我还没有发现这是在属性表....)这似乎只需要静态的libs。
#9
0
before going for the step "compile -DIPLIB=NONE filename.cxx" take the path of VIsual Studio installation upto the vcvarsall batch file and change the configuration as shown below.
在执行步骤“编译-DIPLIB=NONE文件名”之前。在vcvarsall批处理文件上执行VIsual Studio安装路径,并更改配置,如下所示。
*C:\apps\MVS9\VC\vcvarsall.bat x86_amd64*
* C:\ apps \ MVS9 \ \ vcvarsall VC。蝙蝠x86_amd64 *
now next step should be
下一步应该是
compile -64bit -DIPLIB=none filename.cxx
编译-64位-DIPLIB = filename.cxx
this solved the problem for me
这就解决了我的问题
#10
0
Thanks for the answers guys. My problem was that I changed a x64 solution in Visual Studio to 32 bit in the Configuration Manager only. I ended up just creating a new solution as 32 bit and then copying my C++ code and this error was gone. I think l00g33k and RogerAttrill's suggestions may have been the solution, but mine worked, too.
谢谢你们的回答。我的问题是,我将Visual Studio中的x64解决方案更改为仅在Configuration Manager中的32位。最后我创建了一个32位的新解决方案,然后复制了c++代码,这个错误就消失了。我认为l00g33k和RogerAttrill的建议可能是解决方案,但我的建议也是可行的。
#11
0
Recently,I also encountered this problem. That's because I used qt(x64
) in vs win32
. If you want to use qt application x64
, you could choose vs x64
--as the above. If you want to use win32
and perhaps you haven't,you need to download qt(32bit
),then correctly set your enviroment, such as the lib
directory, etc.(note: maybe you are is old set in x64(other version)
, if you convert your win32 or x64 into another, Additional Dependencies
includes the old directory!)
最近,我也遇到了这个问题。那是因为我在vs win32中使用了qt(x64)。如果您想使用qt应用程序x64,可以选择vs x64——如上所示。如果您想使用win32,也许您还没有使用,那么您需要下载qt(32位),然后正确地设置环境,例如lib目录,等等(注意:您可能是在x64(其他版本)中设置的旧目录,如果您将win32或x64转换为另一个,那么附加的依赖项包括旧目录!)
#12
0
This problem has nothing to do with the linker, so modifying it's setting won't affect the outcome. You're getting this because I assume you're trying to target x86 but for one reason or another wxcode_msw28d_freechart.lib is being built as an x64 file.
这个问题与链接器无关,所以修改它的设置不会影响结果。您得到这个是因为我假设您正在尝试针对x86,但出于某种原因或其他原因wxcode_msw28d_freechart。lib被构建为x64文件。
Try looking at wxcode_msw28d_freechart.lib and whatever source code it derives from. Your problem is happening there. See if there are some special build steps that are using the wrong set of tools (x64 instead of x86).
试着看wxcode_msw28d_freechart。lib和它派生的任何源代码。你的问题正在那里发生。看看是否有一些特殊的构建步骤使用了错误的工具集(x64而不是x86)。
#1
32
The error is explicit, you are trying to link libraries that were compiled with different CPU targets. An executable image can only contain pure x86 (32-bit) or pure x64 (64-bit) code. Mixing is not possible.
错误是显式的,您正在尝试链接使用不同CPU目标编译的库。可执行映像只能包含纯x86(32位)或纯x64位(64位)代码。混合是不可能的。
You change the target CPU by creating a new configuration for the project, only changing the linker setting isn't enough. Build + Configuration Manager, Active solution platform combo on upper right, choose New and select x64. That creates a new configuration with several modified project settings, most importantly the compiler that will be used.
您通过为项目创建一个新的配置来更改目标CPU,仅更改链接器设置是不够的。构建+配置管理器,活跃的解决方案平台组合在右上角,选择New并选择x64。这样就创建了一个带有几个修改过的项目设置的新配置,最重要的是将使用的编译器。
Beware that prior to VS2010, the 64-bit compilers are not installed by default. If you don't see x64 in the platform combo then you'll need to re-run setup.exe and turn on the option to install the 64-bit compilers. Then also re-run any service pack installer you may have applied.
注意,在VS2010之前,64位编译器不是默认安装的。如果您在平台组合中没有看到x64,那么您需要重新运行安装程序。执行并打开安装64位编译器的选项。然后重新运行您可能已经应用的任何服务包安装程序。
A possible approach with less pain points is to use the 32-bit version of the library.
一种更少痛苦点的方法是使用32位版本的库。
#2
17
I bumped into this too and found a solution.
我也碰到了这个问题,找到了解决办法。
First on how I got into this problem. I have a project which builds in x86. Then I use the Configuration Manager to add x64, and I hit this problem.
首先谈谈我是如何陷入这个问题的。我有一个在x86上构建的项目。然后我使用Configuration Manager添加x64,然后遇到这个问题。
By looking at BuildLog.htm carefully, I see both of these listed as linker options: /MACHINE:X64
/machine:X86
通过观察BuildLog。仔细地看一下htm,我发现这两种方法都被列为链接器选项:/MACHINE:X64 /MACHINE: X86
I can't find any where in the Property Pages dialog where I can change this, so I open up the .vcproj file and look for the appropriate line and change it to: AdditionalOptions=" /STACK:10000000 /machine:x64 /debug"
在属性页对话框中,我找不到可以更改的地方,所以我打开.vcproj文件,查找适当的行并将其更改为:AdditionalOptions=" /STACK:10000000 /machine:x64 /debug"
and it works.
和它的工作原理。
#3
5
Go to project properties-> configuration properties -> Librarian Set Target Machine to MachineX64 (/MACHINE:X64)
转到项目属性—>配置属性—> library将目标机设置为MachineX64 (/ Machine:X64)
#4
5
In my case it appears it was because I had "copied settings" from a 32-bit to a new configuration (64 bit) and it hadn't updated the libraries. Odd.
在我的例子中,这似乎是因为我将设置从32位“复制”到新的配置(64位),而它没有更新库。奇数。
1>MSVCRTD.lib(ti_inst.obj) : fatal error LNK1112: module machine type ‘X86’ conflicts with target machine type ‘x64’
1>MSVCRTD.lib(ti_inst.obj):致命错误LNK1112:模块机类型‘X86’与目标机类型‘x64’冲突
this meant “your properties -> VC++ Directories -> Library Directories” is pointing to a directory that has 32 bit libs built in it. Fix somehow!
这意味着“您的属性-> vc++目录->库目录”指向一个包含32位libs的目录。修复不知怎么的!
In my case http://social.msdn.microsoft.com/Forums/ar/vcgeneral/thread/c747cd6f-32be-4159-b9d3-d2e33d2bab55
在我的例子中http://social.msdn.microsoft.com/forums/ar/vcgeneral/thread/c747cd6f - 32 - 4159 - b9d3 d2e33d2bab55
ref: http://betterlogic.com/roger/2012/02/visual-studio-2010-express-64-bit-woe
裁判:http://betterlogic.com/roger/2012/02/visual工作室- 2010表达- 64位的有祸了
#5
2
Since the problem is due to the difference in compilation and target machine specifications (x86 & x64) Follow the steps below:
由于问题是由于编译和目标机器规范(x86 & x64)的差异导致的,下面的步骤如下:
- Open the C++ project that you want to configure.
- 打开要配置的c++项目。
- Choose the Configuration Manager button to open the Configuration Manager dialog box.
- 选择Configuration Manager按钮以打开Configuration Manager对话框。
- In the Active Solution Platform drop-down list, select the option to open the New Solution Platform dialog box.
- 在活动解决方案平台下拉列表中,选择打开新解决方案平台对话框的选项。
- In the Type or select the new platform drop-down list, select a 64-bit platform.
- 在类型或选择新平台下拉列表中,选择一个64位平台。
This solved my problem.
这解决了我的问题。
#6
1
Try changing every occurence of .\Release into .\x64\Release in the x64 properties. At least this worked for me...
试着在x64属性中把每一次发生的。\版本改为。\x64\版本。至少对我来说是这样的……
#7
0
I know this is a bit old, but I thought I would provide another tip. In my situation, I inherited this application that I had to maintain. The VS2008 project came with the same string in C/C++->OutputFIles->"ObjectFIleName" and "Program Database File Name" (for both platforms Win32 and x64). So when I built Win32 platform, it built fine, but when I tried to build x64, I got the error:
我知道这有点旧了,但我想我可以提供另一个提示。在我的情况下,我继承了这个必须维护的应用程序。VS2008项目在C/C+ ->输出文件->“ObjectFIleName”和“Program Database文件名”(用于Win32和x64平台)中使用了相同的字符串。因此,当我构建Win32平台时,它构建得很好,但是当我尝试构建x64时,我得到了一个错误:
\Debug64\Objects\common.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
\ Debug64 \ \常见的对象。obj:致命错误LNK1112:模块机类型‘X86’与目标机类型‘x64’冲突
Obviously, both patforms were storing common.obj at the same location, so when I tried to build x64, the linker took the existing object file, which was x86.
显然,这两种模式都是通用的。obj位于同一个位置,因此当我尝试构建x64时,链接器获取了现有的x86对象文件。
To fix I just replaced the existing string with the macro "$(IntDir)\" for x64 (no quotes), and made sure that the macro resolved to the correct path, as in the rest of the projects. That solved my problem.
为了修复,我用x64(没有引号)的“$(IntDir)\”宏替换了现有的字符串,并确保宏解析为正确的路径,如其他项目中所示。这解决了我的问题。
#8
0
An update to i00g's and Thomas' answers, this time for VS2012 (some names have changed). After copying x86 settings over into an x64 target with the configuration manager, you'll have the problem for the same reason as was the case earlier (lib targets aren't correct in the x64 config). Open your .vcxproj (text editor) and replace MachineX86 with MachineX64 where appropriate. (I still haven't found where this is on the property sheets....) This only seems to be necessary with static libs.
更新i00g和Thomas的答案,这次是VS2012(有些名字已经改变)。在使用configuration manager将x86设置复制到x64目标之后,您将遇到与前面情况相同的问题(在x64配置中,lib目标不正确)。打开.vcxproj(文本编辑器),在适当的情况下将MachineX86替换为MachineX64。(我还没有发现这是在属性表....)这似乎只需要静态的libs。
#9
0
before going for the step "compile -DIPLIB=NONE filename.cxx" take the path of VIsual Studio installation upto the vcvarsall batch file and change the configuration as shown below.
在执行步骤“编译-DIPLIB=NONE文件名”之前。在vcvarsall批处理文件上执行VIsual Studio安装路径,并更改配置,如下所示。
*C:\apps\MVS9\VC\vcvarsall.bat x86_amd64*
* C:\ apps \ MVS9 \ \ vcvarsall VC。蝙蝠x86_amd64 *
now next step should be
下一步应该是
compile -64bit -DIPLIB=none filename.cxx
编译-64位-DIPLIB = filename.cxx
this solved the problem for me
这就解决了我的问题
#10
0
Thanks for the answers guys. My problem was that I changed a x64 solution in Visual Studio to 32 bit in the Configuration Manager only. I ended up just creating a new solution as 32 bit and then copying my C++ code and this error was gone. I think l00g33k and RogerAttrill's suggestions may have been the solution, but mine worked, too.
谢谢你们的回答。我的问题是,我将Visual Studio中的x64解决方案更改为仅在Configuration Manager中的32位。最后我创建了一个32位的新解决方案,然后复制了c++代码,这个错误就消失了。我认为l00g33k和RogerAttrill的建议可能是解决方案,但我的建议也是可行的。
#11
0
Recently,I also encountered this problem. That's because I used qt(x64
) in vs win32
. If you want to use qt application x64
, you could choose vs x64
--as the above. If you want to use win32
and perhaps you haven't,you need to download qt(32bit
),then correctly set your enviroment, such as the lib
directory, etc.(note: maybe you are is old set in x64(other version)
, if you convert your win32 or x64 into another, Additional Dependencies
includes the old directory!)
最近,我也遇到了这个问题。那是因为我在vs win32中使用了qt(x64)。如果您想使用qt应用程序x64,可以选择vs x64——如上所示。如果您想使用win32,也许您还没有使用,那么您需要下载qt(32位),然后正确地设置环境,例如lib目录,等等(注意:您可能是在x64(其他版本)中设置的旧目录,如果您将win32或x64转换为另一个,那么附加的依赖项包括旧目录!)
#12
0
This problem has nothing to do with the linker, so modifying it's setting won't affect the outcome. You're getting this because I assume you're trying to target x86 but for one reason or another wxcode_msw28d_freechart.lib is being built as an x64 file.
这个问题与链接器无关,所以修改它的设置不会影响结果。您得到这个是因为我假设您正在尝试针对x86,但出于某种原因或其他原因wxcode_msw28d_freechart。lib被构建为x64文件。
Try looking at wxcode_msw28d_freechart.lib and whatever source code it derives from. Your problem is happening there. See if there are some special build steps that are using the wrong set of tools (x64 instead of x86).
试着看wxcode_msw28d_freechart。lib和它派生的任何源代码。你的问题正在那里发生。看看是否有一些特殊的构建步骤使用了错误的工具集(x64而不是x86)。