Linking errors in Poco with Conan package manage on Windows [duplicate] - c++

I have a project which i have generated with cmake and running in visual studio 2010.I changed the configuration to x64,in visual studio my active solution and the Target Machine in(Properties->Linker->Advanced) is set as x64.I still get the linker LNK1112 error.Is this something which i set in cmakelist.txt if so what is the command?
-swetha

It's not something you'd want to set in CMakeLists.txt. Basically, CMake has multiple generators for different compilers. (The x86 and x64 compilers are two distinct compilers on Windows.) When you generate the build files, you need to pass along the correct compiler for CMake to use, or if you use the GUI, select Win64. From the command line:
cmake -G "Visual Studio 14 Win64" path/to/your/CMakeLists.txt
or whatever version of Visual Studio you want. You can see the available generators with:
cmake --help
If this didn't solve your problem, try it again after deleting the generated build files.
If that still doesn't solve the issue, you are linking to a third party dependency built for x86.

Try to delete all *.obj files in your solution and let compiler compile all files again. This problem may cause of compiler try to reference obj files that was compiled x64

Related

Cmake boost looking for wrong architecture type [duplicate]

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.
When I do:
find_package(Boost
1.67.0
COMPONENTS
atomic
REQUIRED
)
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
But instead of looking for this:
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
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?
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
Thanks in advance for the help!
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"
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.

Force CMake to look for x64 bit libraries instead of 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.
When I do:
find_package(Boost
1.67.0
COMPONENTS
atomic
REQUIRED
)
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
But instead of looking for this:
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
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?
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
Thanks in advance for the help!
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"
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.

How to cmake, make and compile C++14 on Windows

I'm trying to compile, on Windows 10, a C++ project that is using C++14 features such as std::make_unique<> and things like that.
I'd like to be able to compile easily in command line, using CMake and make and then be able to run my program from any command line or just by clicking it's executable.
Compiling using Cygwin, even if it's indeed working (I used this tutorial), is not an option since the resulting executable won't be usable outside of the Cygwin environment due to missing DLLs.
I've read about MinGW-w64, but it seems like the latest available version for Windows corresponds to GCC 4.8.3.
Same goes for the MinGW installer mingw-get-setup.exe available here, wich only allows me to install the 4.8.1-4 version.
So I'd like to have a procedure on how to compile a C++14 project using CMake, and that will allow me to launch the executable in the default Windows environment.
Thanks.
Update : Chris Drew commented that I could use the latest Visual Studio version to build my project using the Visual C++ compiler instead of GCC. I detailed the workflow in my answer, but I'm still looking for a "GNU-style" way to compile it.
"GNU-style" : Use the link provided in Tive's comment to install a working GCC 5.1 environment and use the normal cmake . -G"Unix Makefiles" && make commands.
See this answer for more details on both solutions.
Using Visual Studio compiler
Following Chris Drew comment, here's what I did in order to compile using CMake to generate a Visual Studio 2015 solution and compile this solution in command line.
Note that this is not using the GNU toolchain as we won't be using gcc / make but the Visual C++ Compiler.
Creating and moving to a build subdirectory (it's recommended since it will generate a lot of files, instead of just a standard Makefile) :
mkdir build && cd build
Generating the Visual Studio 2015 solution :
cmake . -G"Visual Studio 14 2015"
This will generate several project files including YourProjectName.sln that we will use to build the project using the following command :
msbuild YourProjectName.sln
Note that msbuild was not in my PATH, so I had to provide the complete path to the executable wich was, in my case, C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe.
Using an updated MinGW installer
Tive provided a link to a bundled installer that will automatically install GCC 5.1 on your system, this way you can use the normal GNU toolchain by generating an Unix Makefile, and using the make command.
Note that you will need to edit your PATH manually as the installer is not doing it for you.

How do I build boost with Visual Studio 2008 when I have multiple Visual Studio versions installed?

I know how to build boost with the latest visual studio on my machine (this question, for example)
However, I need to build the libs for Visual Studio 2008 (vc9)
I tried using toolset=vc9 but I get problems/no success.
How can I build the libs for vc9?
After I run boostrap I try running
b2 toolset=vc9
but the output is:
C:/Development/boost
50/boost_1_50_0/boost_1_50_0/tools/build/v2/build\toolset.jam:39: in
toolset.using rule vc9.init unknown in module toolset
C:/Development/boost
50/boost_1_50_0/boost_1_50_0/tools/build/v2\build-system.jam:481: in
process-explicit-toolset-requests
C:/Development/boost
50/boost_1_50_0/boost_1_50_0/tools/build/v2\build-system.jam:562: in
load
C:\Development\boost
50\boost_1_50_0\boost_1_50_0\tools\build\v2/kernel\modules.jam:283: in
import
C:\Development\boost
50\boost_1_50_0\boost_1_50_0\tools\build\v2/kernel/bootstrap.jam:142:
in boost-build
C:\Development\boost 50\boost_1_50_0\boost_1_50_0\boost-build.jam:17:
in module scope
toolset=msvc-9.0
I have VS2008-Pro and VS2010-Express installed. The default ran with VS2010. Setting toolset=msvc-9.0 caused the build to run with VS2008. Using Boost 1.51.0.
You'll need to dig into the How-To-Build-Boost documentation, and in particular see this;
but the part you need to specify a particular MSVC version is pointed to here. That suggests creating a user-config.jam, which probably would work, but I created a project-config.jam file instead.
I seem to be able to do this by running the top-level boost build (or meta build) script from different VC command lines. For example to build with VC2012, start a command line with vc 2012 vars. And for 2010, do the same. The automatically generated build scripts seem to do the right thing.
I am sure there are ways to do this by editing the build scripts myself or by setting the toolset, but I had no success with that.

How to compile opencv with visual studio without CMake

I want to compile opencv with visual studio, so the code of opencv will be on my computer like all other local code. i.e. i want to be able to change it and debug it.
I can't find anywhere a simple directory file with all the opencv files. It is segmented into include files, modules and similar.
All explanations in the opencv documentations use CMake.
I don't understand what exactly is CMake and why would I need it in order to compile the library locally just like all other regular code.
Can anybody explain me how to do this?
cmake is an platform independent makefile. You can generate from cmake also visual studio projects, which can than imported into visual studio. But you need to install cmake on your computer.
To make a visual studio project call cmake like this:
cmake -G "Visual Studio 9 2008"
Cmake Wiki