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
Related
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?
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'
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.
I think it is possible but I just can’t get the following libs to build as 64 bit as they are built as part of the project but don't take on the bitness of the project (they are built using cppan/cmake):
C:\Users\Bruce.cppan\storage\lib\amd64-msvc-19.0-32\Debug\pvt.cppan.demo.leptonica-master.lib
: warning LNK4272: library machine type 'X86' conflicts with target
machine type 'x64'
4>C:\Users\Bruce.cppan\storage\lib\amd64-msvc-19.0-32\Debug\pvt.cppan.demo.gif-5.1.4.lib
: warning LNK4272: library machine type 'X86' conflicts with target
machine type 'x64'
4>C:\Users\Bruce.cppan\storage\lib\amd64-msvc-19.0-32\Debug\pvt.cppan.demo.jpeg-9.2.0.lib
: warning LNK4272: library machine type 'X86' conflicts with target
machine type 'x64'
4>C:\Users\Bruce.cppan\storage\lib\amd64-msvc-19.0-32\Debug\pvt.cppan.demo.openjpeg.openjp2-2.1.2.lib
: warning LNK4272: library machine type 'X86' conflicts with target
machine type 'x64'
4>C:\Users\Bruce.cppan\storage\lib\amd64-msvc-19.0-32\Debug\pvt.cppan.demo.png-1.6.23.lib
: warning LNK4272: library machine type 'X86' conflicts with target
machine type 'x64'
4>C:\Users\Bruce.cppan\storage\lib\amd64-msvc-19.0-32\Debug\pvt.cppan.demo.tiff-4.0.6.lib
: warning LNK4272: library machine type 'X86' conflicts with target
machine type 'x64'
4>C:\Users\Bruce.cppan\storage\lib\amd64-msvc-19.0-32\Debug\pvt.cppan.demo.zlib-1.2.8.lib
: warning LNK4272: library machine type 'X86' conflicts with target
machine type 'x64'
4>C:\Users\Bruce.cppan\storage\lib\amd64-msvc-19.0-32\Debug\pvt.cppan.demo.webp-0.5.1.lib
: warning LNK4272: library machine type 'X86' conflicts with target
machine type 'x64'
To build as 64 bit:
Download and install Git, CMake and put them in PATH.
Download the latest CPPAN (C++ Archive Network https://cppan.org/) client from https://cppan.org/client/. CPPAN is a source package distribution system. Add CPPAN client in PATH too. (VS2015 redist is required.)
If you have a release archive, unpack it to tesseract dir. If you're using master branch run
git clone https://github.com/tesseract-ocr/tesseract tesseract
Run
cd tesseract
cppan
mkdir build && cd build
cmake .. -DSTATIC=1
Build a solution (tesseract.sln) in your Visual Studio version.
But I omit the –DSTATIC=1 to get shared.
And I add a new configuration to the solution x64 then I removed the hard coded /machine:X86 from the tesseract and tesseractmain Additional Options in the Linker section.. but the libs built via the cppan-dummy project are still 32 bit.
Ideas?
Regards
Bruce
After a lot of digging and learning about the MSVC build system, if you want a 64 bit shared .dll and .lib import library do this:
goto: https://github.com/peirick/VS2015_Tesseract
Clone the repo.
Change build_tesseract.bat to 64 bit Debug, don't forget to change call "%programfiles% (x86)\Microsoft Visual Studio
14.0\VC\vcvarsall.bat" amd64. Run build_tesseract.bat.
Specify TESS_EXPORTS in Preprocessors definitions of libtesseract project and also change it to .dll from .lib
This might be blindingly obvious to someone in the know, the difficult bit was working out the TESS_EXPORTS bit, only mentioned in code as far as I can tell and also using the above repo as it has all the dependencies. Props to peirick for setting up the repo and getting it all sorted.
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);