配置FreeImage静态库

来源:互联网 发布:pi实时数据库 编辑:程序博客网 时间:2024/05/16 13:51

配置FreeImage静态库:

1、从http://freeimage.sourceforge.net/download.html下载FreeImage源代码;

2、打开工程,只需要在Debug和Release两种模式下编译FreeImageLib项目,在FreeImage\Dist中生成FreeImaged.lib(Debug下)和FreeImage.lib(Release下);

3、打开你的工程,在工具--选项--项目和解决方案--VC++目录--包含文件和库文件中添加FreeImage.h和前面生成的两个lib文件;

4、在你的工程属性--配置属性--C/C++--预处理器--预处理器定义中添加FREEIMAGE_LIB;将代码生成--运行时库修改为多线程DLL(/MD)(Debug状态下为多线程调试DLL(/MDd));

5、在工程属性--配置属性--链接器--输入中添加FreeImaged.lib和FreeImage.lib;将忽略特定库修改为LIBCMT;

6、在你的程序开始处调用FreeImage_Initialise(),结束后调用FreeImage_DeInitialise(),编译你的工程;

 

 

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.
Note: Do not compile the FreeImage DLL (project named FreeImage) but the project named FreeImageLib. This should produce a huge file named FreeImage.lib (in release mode) or FreeImaged.lib (in debug mode) in the Dist\ directory.

 

2. Copy FreeImage.lib/FreeImaged.lib into your lib\ directory or in a directory where the linker can find them (e.g. your project directory). You can use "Menu->Tools->Options->Directories->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 -> Project -> 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 -> Project -> 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.