Building & Linking FreeImage with Visual Studio Express 2013

房东的猫 提交于 2019-12-23 00:50:09

问题


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:

  1. Download FreeImage Source.

  2. Open the 2008 Solution (converted to 2013) and changed Code Generation to /MDd for all projects

  3. 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.

  4. 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.

  5. Built the project -> success

  6. Copied Fresh FreeImaged.lib to to my project

    • Added directory to "Additional Library Directories"
    • Added FreeImaged.lib to Additional Dependencies under linker
  7. Copied FreeImaged.dll to my debug folder where the .exe is being built

  8. Added FreeImage.h to the project

  9. Added #define FREEIMAGE_LIB before including the header

  10. 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.


回答1:


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



回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/21085997/building-linking-freeimage-with-visual-studio-express-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!