Linking FreeImage as a static library in VS2010?

早过忘川 提交于 2019-12-01 16:20:25

Yes, I've been able to link FreeImage statically on several Visual studio versions. Here I describe how I do this usually.

With FreeImage, by default, we have 8 options to link it to your app:

FreeImage - dynamic link (you will need dll).

FreeImageLib - static link.

Each of these can be built with "Debug" or with "Release" configurations and for Win32 or Win64 platforms.

So, assume that we need ( Static && Win32 && Debug ) and ( Static && Win32 && Release ) variants for our app. Also in our app we use Dynamic Runtime Library (by default, FreeImage set up for static for some reason) How we usually got it:

  • Download and unpack fresh version (or at least clean up old distib)

  • Open FreeImage.2008.sln select ALL of 10 projects with Shift+click. Then in "Project(s) Properties / C++ / Code generation" we choose /MDd for "Debug" configuration and /MD for "Release".

  • Then we go to "Menu / Build / Batch build", select:

    FreeImageLib | Debug | Win32

    FreeImageLib | Release | Win32

and press "Build".

  • Wait for choosen configurations built. All what we need will be copied in FreeImage\Dist folder

  • in FreeImage\Dist folder check files: delete.me FreeImage.h FreeImage.lib FreeImaged.lib Check creation date and time. It must be fresh baked and hot. If they not, copy them from FreeImage\Source\FreeImageLib\Debug and FreeImage\Source\FreeImageLib\Release.

  • In main applicaion add to include and lib FreeImage\Dist and link FreeImaged.lib to Debug configurations and FreeImage.lib to Releases.
  • Include in source file:

    #define FREEIMAGE_LIB

    #include "FreeImage.h"

  • Try to call FreeImage_Initialise(); FreeImage_DeInitialise();

  • It should work

Happy coding!

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