天天看点

VS2010下静态链接FreeImage

静态链接FreeImage的方法类似下面帖子:

<a href="http://h2appy.blog.51cto.com/609721/1408087" target="_blank">http://h2appy.blog.51cto.com/609721/1408087</a>

主要注意的是:

1. 下载FreeImage,用vs2010打开solution。编译FreeImageLib这个项目。

FreeImageLib项目中编译好的freeimaged.lib就是要使用的库文件。

2. 添加预编译参数:FREEIMAGE_LIB

3.调用时使用下面两个函数:

FreeImage_Initialise()

FreeImage_DeInitialise()

参考:

How to use FreeImage as a static library (Visual C++ 6) ?

Using FreeImage as a static library is not so easy, but it's not more complicated than using any other library. Here is a step by step method to do this :

  1. Compile the FreeImage library in debug and release modes and close your projects. You won't need to use the FreeImage source code anymore.

  2. Copy FreeImage.lib/FreeImaged.lib into your lib\ directory or in a directory where the compiler can find them (e.g. your project directory). You can use "Menu-&gt;Tools-&gt;Options-&gt;Directories-&gt;Library files" for this.

  3. Create a new project and add your code in it.

     Add a call to FreeImage_Initialise() at the beginning of you main function and a call to FreeImage_DeInitialise() at the end of this function.

  4. Edit the compiler options (Menu -&gt; Project -&gt; Settings)

        1. tab C/C++ : Category "Preprocessor"

               * Add FREEIMAGE_LIB to the preprocessor definitions 

        2. tab C/C++ : Category "Code Generation"

               * Use the Multithreaded run-time library (in release mode)

               * Use the Debug Multithreaded run-time library (in debug mode) 

  5. Edit linker options (Menu -&gt; Project -&gt; Settings)

        1. tab Link : Category Input

               * Add FreeImage.lib to the list of object/library modules (release mode)

               * Add FreeImaged.lib to the list of object/library modules (debug mode) 

        2. tab Link : Category Input

               * Add LIBCMT to the Ignore library list (it helps to avoid a warning) 

  6. Compile and link your program  

本文转自 h2appy  51CTO博客,原文链接:http://blog.51cto.com/h2appy/1408320,如需转载请自行联系原作者

继续阅读