Building & Linking FreeImage with Visual Studio Express 2013 - c++

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 :)

Related

C++ detours linking issue

I have problems building my code that is using static lib detours. I am trying to do an old basic CTF. For that I want to get into detours.
Whenever I try to build my .dll file I get an issue
LNK2019 unresolved external symbol _DetourTransactionBegin#0 referenced in function _DllMain#12
Now, I have built the detours library using 3 different version of the visual studio dev console.
I have tried firing 'vcvars32.bat' and then using nmake to build the library which was able to build it, but I get the above error during linking my .dll. I have also tried building it with 'vcvarsamd64_x86.bat' and then using nmake to build it which also was able to build the library, but I still get the same error as above during linking.
I have tried the usual stuff: the include folder for detours.h is added to C++/General/Additional Include Directories.
Under Linker/Additional Library Directories I added them as follows: "C:\temp\det_retry\lib.X64";"C:\temp\det_retry\lib.X86";%(AdditionalLibraryDirectories).
And also under Linker/Input/Additional Dependencies I have the following: detours.lib;%(AdditionalDependencies)
What am I missing here? This is a blocker for me for a couple of days and I am reiterating the same steps trying to figure out what's missing but I cannot see. I'd really appreciate the input.
I am sure I am using the newest version because I have downloaded (cloned) detours from the ms github page.
It appears your "Additional Library Directories" are setup incorrectly or contain invalid entries rather. They look like actual library file entries (i.e. pointing to some specific files) versus being only directories (e.g. "my/lib/path/for/my_project/"). Visual Studio's naming conventions are somewhat cryptic but they should be directory entries only. There should be an entry to whatever directory contains the detours.lib file (e.g. "MyProject/Libs/MSDetour" ... where MSDetour is a folder with the "detours.lib" in it) and then Visual Studio should find the library and link everything correctly.
As a side note, if you are using the Visual Studio developer console for building your project/solution you might want to look into CMake ... it is, in my opinion, significantly easier to work with (less "settings" digging) and maintain in the long-run.

Linking libpqxx from Visual Studio 2015 on Windows 10

I've recently decided to try out PostgreSQL as the database platform for some C++ development I'm working on. I decided to use libpqxx as the connection library for my project, and quickly found out this would be an uphill battle to do from VS 2015 on a Windows 10 machine.
After much teeth-gnashing and nail-biting, I have gotten libpqxx to compile on Windows 10.
This leaves me with the following directory structure
Per libpqxx's documentation, I also placed a copy of libpq.dll in my project's executable directory. Please note: I have done this for both debug and release builds, tried to build both, and ended up with the same result.
All the tutorials I've seen seem to indicate that the library can be used after linking it and simply #including pqxx/pqxx, so I set up a small project to do just that. I receive the error:
fatal error C1083: Cannot open include file: 'pqxx/pqxx': No such file or directory
When attempting to build the project. I have also tried this will both debug and release builds, to no avail.
Here is a screenshot of my linker settings.
Does anyone have any suggestions for how I might be able to link and use this library from Visual Studio 2015?
As Sami Kuhmonen pointed out, this was not actually a linker error, but a compiler error. I needed to include an actual header, which Visual Studio needed to be able to find. After adding the correct folder (C:\libpqxx\include in my case) to Visual Studio's "additional include directories" setting under C\C++ -> General per drescherjm's suggestion, the program compiles just fine.
For future reference:
I did also run into unresolved external linker errors after solving the initial issue. This is because you need to make sure to also link to ws2_32.lib and libpq.lib. You also need to copy some other DLL files that libpq also relies on into your libpqxx lib folder. On my system, I believe these were ssleay32.dll, libeay32.dll, and libintl-8.dll. These files reside under the root of the PostgreSQL install. The DLL step is mentioned under libpqxx's INSTALL.txt file, however I believe it stated that the DLLs resided one folder under where I actually found them.
I have also faced same issue. Then I realized that I was building ,my application as a 32bit. I changed the target to x64 and it compiled successfully

Visual Studio 2013 cannot open 'glfw3.lib'

I'm having a few issues getting GLFW3 set up. I've downloaded the 64-bit binaries from the official site, added glfw3.dll, glfw3.lib and glfw3.h to their respective places, specified the proper include, and added the appropriate linker input to my project. However, when I test the library with glfwInit(), VS spits this out:
error LNK1104: cannot open file 'glfw3.lib' Path/To/Project
My guess was that VS didn't know what directory the library was in, but seeing as it's in the IDE's own lib folder, I don't think this is it. Does anyone have any suggestions? Sorry if this has already been solved, I got in as deep as to read the steps of compilation before I gave up searching.
Edit: I also changed the solution platform to x64, since I am using the 64-bit GLFW binaries.
Following Andon M. Coleman's advice, I moved the headers and library folders to a new directory outside of Visual Studio's built-in ones (D:\opengl-wrappers\lib & D:\opengl-wrappers\include, for example). After including those libraries in the project settings (C/C++->General-> Additional Include Directories and Linker->General->Additional Library Directories), everything compiled beautifully.

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

Visual Studio 2010 Assimp library won't link

I seem to have a perpetual problem of never being able to get any library to link with Visual Studio. Ever. I eventually get tired of trying and just include the header and source files manually.
My latest endeavour is trying to set up Assimp. I went and downloaded the latest version and followed the installation guide for Visual Studio 2010. http://assimp.sourceforge.net/lib_html/install.html
The result:
LINK : fatal error LNK1104: cannot open file 'assimp--3.0.1270-sdk/lib/assimp_release-dll_x64/assimp.lib'
I set the include directories:
assimp--3.0.1270-sdk/include
I set the library directories:
assimp--3.0.1270-sdk/lib/assimp_release-dll_x64
I set the additional dependencies (the guide includes the directories, but shouldn't I just be able to just put assimp.lib since I included the library directory above?):
assimp--3.0.1270-sdk/lib/assimp_release-dll_x64/assimp.lib
What am I doing wrong?
Also, considering this isn't my first time having these difficulties, are there any good tutorials to help me understand this process a little better? I've tried searching for it but most are for previous versions of VS...
My guess is you should provide explicitly relative or absolute paths for the library directory.
You're right about the dependency name, assimp.lib is the correct name and the guide is a bit ambiguous here.
Apart from that, you're doing everything right. Provided the lib file exists, it should link.
(assimp co-founder writing here)