本文介绍了让FreeImage与Visual Studio 2010一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被建议一些你不久前使用FreeImage作为C ++图像处理库。

I was advised by some of you not to long ago to use FreeImage as a library for image processing in C++.

我现在在让图书馆工作方面遇到一些麻烦(这里还是比较新的)。

I now have some trouble in getting the library to work (still relatively new here).

我'我试过加载各种vcxproj和sln瓷砖,他们给了我一个空白的项目。由于没有为此提供任何安装说明,我放弃了将其作为视觉工作室解决方案。

I've tried loading the various vcxproj and sln tiles and they gave me a blank project. Since there isn't any installation instructions provided for that, I gave up on making it a visual studio solution.

我接下来尝试了旧方式编译源代码代码使用Makefile,然后将FreeImage / Source添加到链接器。虽然IDE在调用FreeImage.h中声明的函数时没有引发任何红色标记,但它在编译期间给了我一堆错误LNK2019:未解析的外部符号,就好像这些函数不存在一样。我怀疑IDE无法找到定义所述函数的.cpp文件,但是当我将FreeImage / Source / FreeImage添加到链接器时,我仍然遇到同样的问题。

I next tried the old-fashion way of compiling the source code using the Makefile and then adding "FreeImage/Source" to the linker. While the IDE does not raise any red flags when I call functions declared in FreeImage.h, it gave me a bunch of "error LNK2019: unresolved external symbol" during compilation, as if the functions do not exist. What I suspect is that the IDE could not find the .cpp files that define the said functions, but I still get that same problem when I added FreeImage/Source/FreeImage to the linker.

现在当我直接包含一些.cpp文件(即Plugin.cpp和FreeImage.cpp)进行测试时,我得到了更多未解决的外部符号错误以及类似不一致的dll链接之类的内容...例如FreeImage.cpp:

Now when I directly included some of the .cpp files (i.e. Plugin.cpp and FreeImage.cpp) for a test, I get even more unresolved external symbol errors as well as things like "inconsistent dll linkage" for this within... for example FreeImage.cpp:

const char * DLL_CALLCONV
FreeImage_GetVersion(){
static char s_version [ 16];
sprintf(s_version,%d。%d。%d,FREEIMAGE_MAJOR_VERSION,FREEIMAGE_MINOR_VERSION,FREEIMAGE_RELEASE_SERIAL);
返回s_version;
}

所以,我完全陷入困境。我究竟做错了什么?我觉得我已经遵循了添加库依赖项的适当步骤,例如将直接父项的特定文件夹添加到C / C ++中的相关.h和.cpp文件 - >常规 - >其他包含目录和链接器 - >常规 - >添加图书馆目录。

So, I am totally stuck. What am I doing wrong? I felt I've followed the adequate steps in adding library dependencies, such as adding the specific folders that are immediate parents to the relevant .h and .cpp files in C/C++ -> General -> Additional Included Directories and Linker -> General -> Addition Library Directories.

一些帮助将不胜感激!

推荐答案

使用FreeImage v3 .15.3将VS2008项目转换为VS2010没有问题。
此外,该建筑按预期工作。但是当我链接到静态库时,我得到了一些未解析的外部。首先,我尝试了各种技巧设置/ MT / MD链接,但这并没有解决这些链接问题。

Using FreeImage v3.15.3 I had no problems converting the VS2008 project to VS2010.Also the building worked as expected. But when I linked to the static lib, I got some unresolved externals. First I tried al kinds of tricks setting /MT /MD linking, but that did not solve these linking problem.

在阅读了一些新手的评论后,我挖到了freeimage.h。在那里我找到了一个宏开关FREEIMAGE_LIB来控制函数的调用约定。
在包含freeimage.h文件之前使用#define FREEIMAGE_LIB。这样你就可以轻松静态链接到FreeImage.lib

After reading Some Newbie's comment I dug into freeimage.h. There I found a macro switch FREEIMAGE_LIB that controls the calling conventions of the function.Use a #define FREEIMAGE_LIB before including the freeimage.h file. That way you can easily static link to FreeImage.lib

这篇关于让FreeImage与Visual Studio 2010一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!