freeImage静态库连接
来源:互联网 发布:mac有什么好玩的网游 编辑:程序博客网 时间:2024/06/05 19:40
for new coder 通过搜索关键词进来的,希望能起一点参考作用
当然,如果使用dll就简单许多,但我对于附带一个dll这种行为很不爽,于是想用静态库连接一下
在大概弄明白原理之后就下源码,选择静态库编译,然后分别得到debug 和 release 的 lib,再使用
#ifdef _DEBUG
#pragma comment(lib,"FreeImageD.lib")
#else
#pragma comment(lib,"FreeImage.lib")
#endif
链接到程序里,结果嘛肯定是报错了,然后就开始了漫长的排错之旅 ,不想写成记叙文了,简单说要点吧
1 如果在编译lib库时项目属性的c/c++ 代码生成的运行时库的debug和release 选择 /MDd 和/MD 自己工程也要这么设置才可以正确连接
2 在预定义宏的部分加上 FREEIMAGE_LIB
完成上面两点的修正才可以正确链接,如果仍有问题 请观看官方因为说明,本人就是因为太急了才绕了一个很大的圈,
提醒自己一下 下次使用类似的开源库一定要看说明
How to use FreeImage as a static library instead of as a DLL (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.
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) (第五条没用到,因为没找到选项,可能只是和vc6.0有关)
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.
- freeImage静态库连接
- 配置FreeImage静态库
- 使用FreeImage静态库的初始化
- iOS freeImage静态库编译(makefile)
- FreeImage
- 图像处理库(FreeImage)
- FreeImage库HDR转JPEG
- makefile连接静态库
- 多重静态库连接
- 静态连接库
- VC++静态连接库
- cmake连接静态库
- 图像库OpenCV/FreeImage/CImg/CxImage
- 四大图像库:OpenCV/FreeImage/CImg/CxImage
- 四大图像库:OpenCV/FreeImage/CImg/CxImage
- 四大图像库:OpenCV/FreeImage/CImg/CxImage
- 四大图像库:OpenCV/FreeImage/CImg/CxImage
- 四大图像库:OpenCV/FreeImage/CImg/CxImage
- c# 导出table中的数据到模板excel中
- 堆和栈的区别(转过无数次的文章)
- VisualLeakDetector 使用要点
- 与路由相关的常用度量值
- GCC内联汇编(简洁明了)
- freeImage静态库连接
- Linux 汇编语言开发指南
- spring整合struts配置方式(简要)
- 开博
- 随机函数
- Linux设备驱动程序--与硬件通信18051101072
- 我的测试历程091227
- 中英文截取指定长度的字符,保证不会出乱码,截取最终长度为length,或length-1
- TomCat 配置其启动路径和get编码格式