How could I migrate a win32 application to a x64 one? - c++

Recently I worked on a facial recognition application in Visual Stuido 2015. In order to apply cuda libraries to the app, this app needs to migrate from win32 type to x64. I carefully change the configuration manager and moderate everything involved with x86 when making sure every extern dll or lib has its x64 version.
But after compiled in release mode, there is always a error message: "LNK1112 module computer type 'x86' conflicts target computer type 'x64'". The error file is CameraDS.obj which is written by directshow. And I checked the producing .obj files with dumpbin /headers, then discovered the header file values of every .obj is machine (x86). Delete these .obj files or just clean solution doesn't work, and the IDE just throws the same error message. I don't konw why.
Is there any solution?

Is it the source of the lib CameraDS.obj?
https://github.com/souseiki/Stereo-Vision
Just recompile it for x64 as well.
Also check that you haven't left x86 anywhere, look at the answers of fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

Related

Boost module machine type 'X86' conflicts with target machine type 'x64'

I am building a 64bit program on Windows and need to link to a Boost library.
I am using other 64bit libraries successfully.
When I built boost I specified exactly that I need 64bit libraries using the command
`.\b2 address-model=64'
And it built the library I need:
`libboost-serialization-vc120-mt-s-x64_1_77.lib'
This should be a 64bit library as its name implies.
However when I try to compile my program I get the linking error:
Description:
`error LINK1112: module machine type 'X86' conflicts with target machine type 'x64'
File:
`libboost-serialization-vc120-mt-s-x64_1_77.lib'
What's going on - it is a 64bit library why is it saying that it conflicts with machine type 'x64' and what can I do about it?
Ok, I "figured out" how to get round this.
Basically, what I thought was happening was happening. Despite specifying a 64bit build and those libraries getting the name appropriate to a 64bit build, they were being built using the 32bit tool-chain.
To anyone from Boost who happens to see this - this is a REALLY bad experience and should be fixed
To get it to build the libraries correctly I had to run a .bat script hidden away in the MSVC program files to set the environment to 64bit before the usual boost procedure.
There are a variety of these scripts for different purposes as detailed here, although infuriatingly it doesn't specify where to find them.
After hunting around for them I found the file I needed vcvarsx86_amd64.bat (for complicated reasons I'm using an old version of MSVC which only comes in a 32bit flavor but can cross-compile 64bit code).
For me this was found in
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat
Note: for any of this to work this all has to be done inside a developer command prompt which for me was located at
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
Once in the that command prompt the proper library files were then built by typing
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat
bootstrap vc12
b2 address-model=64
Then it linked as expected.
Disclaimer: Unnecessary opinion - feel free to edit this away...
Coming from *nix environments, all of this seems terrible. Boost is essential to c++ development, but just getting it to build with MSVC is so incredibly contrived, opaque, and just... broken. Almost like it is designed to make it difficult. How do you put up with it?

Module machine type and target machine type Visual Studio 2013

I am running a project with platform WIN32 but my laptop is 64bit. So if I choose the target machine type x64 it will announce :
error LNK1112: module machine type 'X86' conflicts with target machine 'x64' File opencv_ts300.lib
Then when I change the target machine type X86 it will announce
error LNK1112: module machine type 'x64' conflicts with target machine 'X86' File Assemblyinfo.obj.
So what should I do? Please help me. Thank you
Your solution configuration isn't correct. Looks like you mismatched builds in VS "Configuration Manager". Also, it looks like your opencv_ts300.lib is built for x64, so if you don't have x86 built of opencv then you'll have to switch all your projects to x64 as well.
You can't use inline assembly in Visual Studio x64 mode. The assemblyfile.obj is most likely written for x64 anf can't be linked to a x86-compiled c program thereby, causing the second error.

Qt module error - LNK 1112 in QtOpenGL

I am trying to build a project (x64) connected with Qt library in Microsoft Visual Studio 2010. The project I want to compile was built using Visual Studio 2008.
I have all the dependencies added, downloaded compiled the Qt library 64-bit and done all the proper changes in project properties in VS 2010. Although, I get the error below:
Error 2616 error LNK1112: module machine type 'X86' conflicts with
target machine type 'x64' D:\project\Windows\QtOpenGL4.lib(QtOpenGL4.dll)
I have checked my .dll and .lib files and they are an in x64 bit version. Also, my QtOpenGL4.dll file is in another path from the one mentioned in error.
Could it be an error from the QtOpenGL4 module? How could I solve this? Could you please help me?
The instructions I followed in order to build the 64-bit version of Qt are in this link : https://en.wikibooks.org/wiki/Opticks_Developer_Guide/Getting_Started/Building_Qt_From_Source
Finally I found a solution in my error. I compiled again the Qt library in 64-bit and entered all the proper values in project Properties. I also entered the proper path in
Project Properties -> Linker ->Input ->Additional Dependencies.
With the right paths it solved the linkage error for me.
I have to mention that I also downloaded the precompiled libraries from the answers in this link
How to compile Qt for 64-bit Windows from a 32-bit environment with Visual C++ 2010 Express?
You are probably trying to link your 64-bit project with 32-bit Qt libraries.
This says more about the error you are facing.
Similarly, if you create one module with the x64 compiler and another
module with the x86 compiler, and try to link them, the linker will
generate LNK1112.
Check if you are using 64-bit precompiled Qt libraries.

Failing to build Boost 1.60.0 on Windows 10

I've used the Getting Started Guide that is provided from Boost.
Many of the existing problems with somewhat related nature seem to occur within Visual Studio and be due to faulty project settings and linking in particular.
My problems lies in actually getting Boost to build using the Developer Command Prompt for VS2015 and running it as admin.
First I just extracted the folder and ran the VS2015 command prompt from the root folder with
bootstrap.bat
which gave me the following output
C:\Program Files (x86)\boost\boost_1_60_0>bootstrap.bat
Building Boost.Build engine
Failed to build Boost.Build engine.
Please consult bootstrap.log for further diagnostics.
You can try to obtain a prebuilt binary from
http://sf.net/project/showfiles.php?group_id=7586&package_id=72941
Also, you can file an issue at http://svn.boost.org
Please attach bootstrap.log in that case.
According to the bootstrap.log a lot of required header files were not found. According to the Visual C++ Team Blog the headers, sources and librares is now distributed on a different location on the user machines. This happend to me! I had to move a ton of headers and lib files from for it to find them.
However..... I can't figure out how to go on from this point.
Looking at your output at the end there are 4 suspicious warnings:
..\kernel32.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'
..\advapi32.lib: warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'
..\user32.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'
..\uuid.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'
Note the machine type, i.e. it probably related to which platform this is running for. Visual Studio Command Prompts come in different forms, make sure that you are running the correct one - In your case the correct one seems to be the VS2015 x64 Native Tools Command Prompt

msvcprtd.lib(MSVCP100D.dll) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

I created a vs 2010 win 32 program (Operation system: Win 8-64bit)
Then, I tried to convert this win32 program in to x64 by doing like this:
Configuration Manager -> new solution platform (select x64) -> copy settings from win32
The vs2010 created a new x64 program based on the previous win32 program.
However, when I tried to compile and run the x64 program, there is a single error:
msvcprtd.lib(MSVCP100D.dll) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
By renaming both win32 version and x64 version of msvcprtd.lib, I found the program is still using the win32 msvcprtd.lib.
I checked and found msvcprtd.lib is in $(VCInstallDir)lib\amd64. Moreover:
Library Directories -> Inherited values has included all the necessary directories (I think):
$(VCInstallDir)lib\amd64
$(VCInstallDir)atlmfc\lib\amd64
$(WindowsSdkDir)lib\x64
I also checked the 3rd party libraries and dlls the program is using are of x64 version.
My question is why the program is still using the win32 msvcprtd.lib and how to solve this problem?
In the project Library Directories, be sure you change
$(VCInstallDir)lib and $(VCInstallDir)atlmfc\lib
to
$(VCInstallDir)lib\amd64 and $(VCInstallDir)atlmfc\lib\amd64
After searching I came across an useful page MSDN Info. "It is a known problem that on occasions VC picks up certain settings from older versions of VC installed and causes these kinds of problems."
For me it worked by adding the following:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64
Anyway, don't hesitate to search the msvcprtd.lib file directly from Visual Studio installation directory.
I have faced same problem.It comes rarely and occasionally when we create new project for X64 platform.
Here is the solution: for X64 platform
In Configuration properties-->
1.Include directories -> $(VCInstallDir)PlatformSDK\include;$(IncludePath);
2.Library directories -> $(VCInstallDir)PlatformSDK\lib;$(LibraryPath);