Linking error while using dlib with libjpeg - c++

I am studying Machine Learning and Pattern Recognition and using dlib library for that. I was trying one example code face_detection_ex.cpp provided with the library. I created a separate project under Visual Studio 2010 and included the face_detection_ex.cpp example and dlib\all\source.cpp files. It build fine. But, if I enable DLIB_JPEG_SUPPORT by
#define DLIB_JPEG_SUPPORT
then it will throw the linking error LNK2019 for all the functions of libjpeg library used by the dlib library. I tried #pragma comment(lib, libjpeg) and I also tried to include the library in project properties, but still the same.
After spending 1 day on this error, I switched to linux and try to work in that. But there also I am getting the same linking errors.
Then on the dlib release-note I read that libjpeg library is included in dlib's external folder and use dlib's cmake file for the example code and cmake will perform the static linking. I tried that and with cmake it is linking. I tried to find out how the linking is happening as I want it to work with visual studio and other compilers also but I couldn't find out why the libjpeg library is unable to link.
Any suggestion?
EDIT: Here it is mentioned how to use dlib with Visual Studio. And how to compile the example on linux. So, as I have to link with libjpeg library, I added the -ljpeg in the command.

You can use CMake to generate a Visual Studio project that is properly configured and that's the easiest way to do this if you want to use Visual Studio.
However, if you really want to configure the Visual Studio project by hand then all you need to do is add the files in the dlib/external/libjpeg folder to your Visual Studio project and also add the dlib/external/libjpeg folder to the include search path.

Related

Use MinGW static library (.a) within Visual studio environment

I work on a project that generate several static libraries (.a) from MinGW with Scons project files.
And I need to use these libs into an other project that work on C++ Visual Studio 2013.
First I tried to just add MinGW lib to my VS project and obviously it didn't work out.
I read some things about using a ".def" file to switch from ".lib" to ".a" but found nothing about convertion from ".a" to ".lib". But I have no idea how to get this ".def" file.
Does anyone have some clue that what I am trying to realise is possible (use MinGW into VS2013) ? Or even a solution that can help me :)
Mathieu.

ITK Library dependencies error

I've been trying to use ITK with visual studio but i've been getting problems with the ITK itself. After sucessfully configuring and compiling ITK with Cmake and creating a new project accordingly, Visual studio can't find the paths of the libraries. I've tried specifying the paths on visual studio directories and even manually introducing them into the code but the problem is: There are hundreds of dependencies within ITK, it would take me weeks to link it all together manually, isn't there a way to make this process easier, or to avoid it at all?
Thank you in advance!
Error message
You might need to reconfigure ITK, but this time disable Module_ITKVtkGlue. Then recompile ITK, and then try compiling your project again. I assume you used CMake to generate your project. An example can be found here.

Building and using OpenCV as a static library with Ffmpeg

I'm trying write an OpenCV application. I've statically built OpenCV from source as I don't want dll files and my project compiles as long as I don't use cv::VideoCapture, in which case I get a link error LNK2019 unresolved external symbol.
I think this is because the cv::VideoCapture uses ffmpeg to work with video, which, because of it's license, cannot be statically linked in my project. I would be ok with linking the ffmpeg dynamically but I'm having trouble doing this. There is a opencv_ffmpeg310_64.dll file in the %OpenCV_DIR%\bin folder, but I'm clueless about how to dynamically link it to my project. Usually I have .lib files that come with the .dll but I can't find them anywhere.
Is it possible to statically link OpenCV and dynamically link ffmpeg, and how should I go about doing this?
Additional info:
Windows 10
Visual Studio 2015
OpenCV 3.1.0 x64 build
I finally got it working. I was wrong thinking I needed ffmpeg to get it working. The problem I had was solved by adding vfw32.lib to the library dependencies in Visual Studio.

Building & Linking FreeImage with Visual Studio Express 2013

I'm having a lot of trouble linking my project with FreeImage library with VSE 2013
I've followed this answer for VS2010 to no avail: Linking FreeImage as a static library in VS2010?
I am getting LNK2019 errors when calling FreeImage functions.
I've linked the library just as I would any library. Below are the following steps I made:
Download FreeImage Source.
Open the 2008 Solution (converted to 2013) and changed Code Generation to /MDd for all projects
Attempted to build project but for some reason min/max functions were not defined So I included algorithm.h to those files and that stopped those errors.
Attempted to build project and I get an error: "Could not open "afxres.h". So I swapped afxres.h with windows.h as suggested in another topic.
Built the project -> success
Copied Fresh FreeImaged.lib to to my project
Added directory to "Additional Library Directories"
Added FreeImaged.lib to Additional Dependencies under linker
Copied FreeImaged.dll to my debug folder where the .exe is being built
Added FreeImage.h to the project
Added #define FREEIMAGE_LIB before including the header
Attempted to build my project -> LNK2019s everywhere.
If anyone has been able to build FreeImage on VS2013 and could share how they did it I would greatly appreciate it, or if anyone has any suggestions.
The reason for your troubles is that with Visual Studio 2013 some breaking changes (as outlined by Microsoft) were introduced in related to C++11 conformity.
One includes that in order to use std::min()/std::max(), you now have to include the header . This also concerns FreeImage. Unfortunately, up until version 3.6.1 (the most recent as of today) this hasn't been fixed yet.
This blog post explains what you need to do to get it to compile. The most relevant part is:
Specifically, you will need to add
include <algorithm>
to the following files:
Source/OpenEXR/IlmImf/ImfOutputFile.cpp
Source/OpenEXR/IlmImf/ImfScanLineInputFile.cpp
Source/OpenEXR/IlmImf/ImfTiledMisc.cpp
Source/OpenEXR/IlmImf/ImfTiledOutputFile.cpp
Source/OpenEXR/Imath/ImathMatrixAlgo.cpp
I was able to get this to work by going into the Configuration Manager unchecking FreeImage and checking FreeImageLib under build. Also disabling whole program optimization seems to make the binary size more normal and, gets rid of warnings when linking.
I know this question is over a year old. Just providing an answer to anyone google searching this problem like me.
version: FreeImage3170Win32Win64.zip
os.env.: win7 64bit visualstudio ULTIMATE 2013
operation:
1_ just unpacking the zip somewhere
e.g. (D:/library/FreeImage3170Win32Win64/FreeImage)
2_ in C/C++->General->Additional Including Directerories
add (D:/library/FreeImage3170Win32Win64/FreeImage/Dist/x32)
3_ in Linker->General->Additional Library Directerories
add (D:/library/FreeImage3170Win32Win64/FreeImage/Dist/x32)
4_ in Linker->Input->Additional Dependency
add (FreeImage.lib)
PS0: i just add a new entry to Include Directories and Library
Directories and FreeImage.lib to Linker->input in Visual Studio without rebuild the FreeImage library
:)
PS1: error LNK2019 occured when i added the FreeImage/Dist/x64 option
;( ( got no idea about this)
maybe this helps :)

Visual Studio 2013 (vs120) asks for wrong boost libraries

I'm trying to compile one of my projects on Windows 7, using Visual Studio 2013. I've installed Boost 1.53 and setup the solution using cmake.
What happens is that now the compiled libraries of boost are in the form libboost_*-vc120-mt(-gd)-1_53.lib. In the linker project options, under the input tab, I have verified that the libraries that I need are there, and in fact the compiler is able to correctly read them.
However, for some reason that I absolutely can't understand, the linker is also trying to find libraries compiled as vc110. For example:
error LNK1104: cannot open file 'libboost_filesystem-vc110-mt-gd-1_53.lib'
The Platform Toolset that is listed in the project option is "Visual Studio 2013 (v120)". I couldn't find any reference to vc110 in any of the project options. Can you help me understand what is happening?
This post thankfully solves my question. I wasn't able to find it before. The solution is to edit the boost/config/auto_link.hpp because the code inside is not able to handle vc120, and ends up suggesting vc110
How do I specify, which version of boost library to link to?
The library name is autogenerated in the boost header version.hpp
Possibly the version wasn't rebuilt, or you are pointing at the wrong header version?
Instead of patching the config file try just defining a macro before the header inclusion .. this is what I did in my project
//#define BOOST_LIB_TOOLSET "vc100"
//#include