How add opencv to Visual Studio 2019? - c++

I added the opencv library and include file to visual studio 2019. (Property pages / VC++ directories / include directories & library directories. also, linker / input / and add the name of the library to this part).Also, I added the bin file to the environment variables. It's working well but every time that I want to work with OpenCV I must do all these things again. This is really boring
Is there another solution to add these files? (I mean no need to add files again)

If you are really looking for the fastest option I would recommend using vcpkg.
Once you set it up and install your needed library, using it in your project is as simple as using the standard library, you just have to include the library headers.

CMake can generate project files for several prominent IDEs, such as Microsoft Visual Studio, Xcode, and Eclipse CDT. It can also produce build scripts for MSBuild or NMake on Windows; Unix Make on Unix-like platforms such as Linux, macOS, and Cygwin; and Ninja on both Windows and Unix-like platforms.

Related

Boost/Array.hpp: No such file or directory (On Visual Studio 2019)

I have included the boost library by going to properties, and then adding the path in the VC++ include directory, and the C/C++ Additional Include Libraries.
I have added the header files using #include<boost/array.hpp> and #include<boost/static_assert.hpp>.
While building, I get warnings regarding the other Boost header files, such as clang.hpp, however, the error message displayed is boost/array.hpp: No such file or directory. Since the warning messages are generated for the other Boost header files, I am assuming that the path has been registered and the Boost files are located by Visual Studio (I am quite possibly wrong about this). What am I doing wrong?
EDIT: I was building a Linux Console Application, and found out my mistake. Have added the answer below.
So I was trying to build on a linux machine remotely (Crucial detail that I had missed out earlier), so I had to insert the path in the format -I "path", to the boost library on the linux machine. I made the mistake of downloading the boost files on the windows machine, and adding the path to the windows boost files instead.
Go to Properties, C/C++, Command Line (Additional Options), and then enter the path over there to the library on the linux machine.
For example: -I /usr/FileSystem/boost_1_72_0

how to install boost/asio.hpp library for C++ visual studio 2015

Hello I am trying to install this library for use in one of my visual studio projects.
I know I have to go to \project properties-linker-general-additional library Directories but once I get there I don't know what to do.
I am stuck here :
Here's a step-by-step tutorial for installing, (optionally) building, and referencing boost in Windows: http://www.boost.org/doc/libs/1_61_0/more/getting_started/windows.html#get-boost
Obtain a copy of boost and put it to a folder boost_root (name as you please). If you haven't done it already, the easiest way is to get a precompiled zip from boost
Find the directory where your boost binaries are located. It usually is under the lib subdirectory, ie boost_root\libs.
Under the Additional library directory of visual studio (the one you mention in your post), enter the full or relative path to the boost dll directory, ie path_to_boost_root\boost_root\libs

qmake: how to remove the dependency of absolute paths?

Qt Creator + VC19 (MSVC2015) + WinSDK8.1
No Qt itself used. Just console application std+boost+catch+easyloggingpp
VC\bin and WinSDK\bin both are in a system path variable.
all includes and lib paths configured in a pro file.
I need to move them out from project file to build this project on various machines (all windows but different locations of the used libraries).
I think that cl.exe can read this from LIB and INCLUDE env variables, but if I do this (set headers and libraries paths from bat file or in a project settings in QT Creator) it doesn't work, QtC reports me that can't find some headers.
Could you clarify for me:
Should Qt Creator read LIB and INCLUDE variables for the build and parsing? What is right steps to make it working?
If Qt Creator can't read the env variables , then what is right way to remove the dependency of absolute paths in project build with qmake?
You obviously have Visual Studio compiler and other standard library paths hardcoded as absolute in your project file?
All the Visual Studio or other compiler settings e.g. tool chain location are normally read by Qt Creator from compiler kit. Adding Compilers article clarifies on that. That is the first thing to configure as long as your system has Visual Studio installed. Having configured compiler kit you will be able to add one to your current project build: Configuring Projects article.
And in case if you build from command line with qmake and jom: your build script may execute the Visual Studio standard environment batch script file like:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\VcVarsAll.bat" amd64
Mind the target bitness (32/64) and actual location of your Visual Studio. There is MSDN article for that: Setting the Path and Environment Variables for Command-Line Builds.

How to link opencv and other dll files to output exe of visual studio 2013

I am new with visual studio, opencv.
I am using visual studio 2013, opencv and c++ for my project.
I configured (copied path) the opencv and other library to my computer environment system.
After run the project in visual studio, normally, there will be an exe file in the project.
I can copy the exe file in the project folder and copy to other place in my computer and it will run normally.
This is because my computer environment systems are configured with opencv and other library.
I want to do the same thing with other computers BUT I do not want to manually configure each computer with opencv and other libraries.
Are there any ways that I can do to link everythings all in exe file after run the project in visual studio 2013 so that I can run the exe without depend on the path of libaries and opencv?
EDITED
I use opencv installer opencv2.4.7.exe
In the current VS2013 my project, i configured my project and opencv installer as this link
http://www.anlak.com/using-opencv-2-4-x-with-visual-studio-2010-tutorial/
question : Can i use the library in folder C:\opencv\build\x64\vc11\staticlib come from the opencv installer no need create my own library from source opencv?
question : In case i need to generate new library from opencv source (http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html) or use lib in static folder of opencv installer, if i want to include it all to exe files, do i need to create new project and reconfigure?
Thank you.
First you need to rebuild openCV to generate static libraries instead of dynamically linked ones. This way all code that your application uses is thrown together in one single exe-file (which will probably be significantly bigger). This exe-file you can move to other computers and they should still work there, provided they have an architecture that is at least compatible with yours. So if you build it on an x86 perconal computer (32-bit), it should basically work on any other personal computer. If you build it on a x64 computer (AMD 64-bit), it will only run on other x64 machines. At least this is true assuming both systems use the same syscall API (Windows NT, POSIX...).
For openCV you do this by setting the BUILD_SHARED_LIBS build flag to false (see OpenCV as a static library (cmake options), the following line is taken from there):
cmake -DBUILD_SHARED_LIBS=OFF ..
Once you have done this, you will see that the openCV folder looks very similar to the one you have now, except that in your 'lib' folder there will now be .lib-files instead of .dll files (at least if you are working on Windows, which I assume you do since you are using Visual Studio).
Next step is to go to your project settings and set your linker to link with the static libraries instead of the dynamically ones. If you have used openCV's local method for linking, you can go to project settings -> linker -> input -> Addtional dependencies. There you change the extension of all the openCV libraries from .dll to .lib.
Now you should be able to rebuild your application and the resulting exe-file should have all dependent libraries contained in it.

Visual Studio - find out why Visual Studio tries to link to class X? [duplicate]

This is what I have done:
Download the 1.54 zip file from the boost website
Extracted/copied it to C:\Program Files (x86)\Boost
Inside Visual Studio I have set the include libraries to: C:\Program Files (x86)\Boost\boost_1_54_0\boost_1_54_0\
(This seems to work fine for getting the compiler to accept the libraries)
Now the bit i'm having problems with- linker:
Inside Visual Studio I have set the linker include directories to: C:\Program Files (x86)\Boost\boost_1_54_0\boost_1_54_0\libs\
When I compile my project I get:
fatal error LNK1104: cannot open file 'libboost_date_time-iw-mt-sgd-1_54.lib'
EDIT Have built the boost binaries using the answer below. However I now have these files:
libboost_date_time-vc110-1_54.lib
libboost_date_time-vc110-gd-1_54.lib
libboost_date_time-vc110-mt-1_54.lib
libboost_date_time-vc110-mt-gd-1_54.lib
libboost_date_time-vc110-mt-s-1_54.lib
libboost_date_time-vc110-mt-sgd-1_54.lib
libboost_date_time-vc110-s-1_54.lib
libboost_date_time-vc110-sgd-1_54.lib
but still no
'libboost_date_time-iw-mt-sgd-1_54.lib'
EDIT: Think I have found the problem:
http://lists.boost.org/Archives/boost/2004/08/70114.php
OK, here's the problem: originally we had one Intel toolset:
"intel-win32" which created the library suffix "iw" (note no version
number!), and this is what the auto-link header currently searches
for.
However people have started adding versioned Intel toolsets, which
means that we now produce an ad-hoc mixture of library names, some
with compiler-version suffixes and some without, the autolink code
could handle either form, but as it's not psychic it can't handle
both :-(
Solution is to #define BOOST_ALL_NO_LIB
On a 64bit system you should build boost in Program Files, not Program Files(x86) the boost automatic library include does not handle the redirection correctly. Alternatively you can manually manage the library inclusion... but I would highly recommend against it.
Also a reminder that you need to build boost in all the flavors and bitnesses you are going to use. See How to use Boost in Visual Studio 2010 for a good example of how to do so.
In an administrator visual studio command prompt go to the boost directory
run bootstrap.bat
run b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64
wait for b2 to finish building
EDIT:
As it turns out the iw in that library refers to the intel compiler... to use that with boost and visual studio you'll need to follow the directions from Intel.