OpenVDB链接器错误:未解析的外部符号

时间:2021-01-08 04:51:48

I wish to use OpenVDB library in a project. The library has compiled successfully on Windows7 x64 in release version using \MD (as described in https://github.com/rchoetzlein/win_openvdb). The OpenVDB_cookbook compiles and executes successfully as well. If I put my own code in cookbook, it compiles and executes successfully as well.

我希望在项目中使用OpenVDB库。该库已在使用\ MD的发行版本的Windows7 x64上成功编译(如https://github.com/rchoetzlein/win_openvdb中所述)。 OpenVDB_cookbook也可以成功编译和执行。如果我将自己的代码放在cookbook中,它也会成功编译并执行。

But,

  • If I link the library to an existing project,

    如果我将库链接到现有项目,

  • or I copy paste the same code (from cookbook) in a new project and use the same cmakelists.txt, Find*.cmake files and all the same options from project properties as from the cookbook,

    或者我复制粘贴相同的代码(来自cookbook)在一个新项目中使用相同的cmakelists.txt,Find * .cmake文件和项目属性中的所有相同选项,如同来自cookbook,

it throws a linker error 'LNK2019: unresolved external symbols "void_cdecl openvdb::v3_0_0::initialize(void)" referenced in function main'

它抛出一个链接器错误'LNK2019:未解析的外部符号“void_cdecl openvdb :: v3_0_0 :: initialize(void)”在函数main中引用

Even the simplest code of the form:

即使是最简单的表格代码:

#include <openvdb.h>
void main()
{
    openvdb::initialize();
}

throws this linker error.

抛出此链接器错误。

Any ideas what am I doing wrong? I am on it for a few days and haven't been able to solve it.

任何想法我做错了什么?我已经上了几天而且无法解决它。

All libraries IlmBase, OpenEXR, glew, glfw, boost and OpenVDB are successfully linked using cmake and are present in the project properties page.

所有库IlmBase,OpenEXR,glew,glfw,boost和OpenVDB都使用cmake成功链接,并存在于项目属性页面中。

Thank you for the help.

感谢您的帮助。

1 个解决方案

#1


0  

The problem was solved by adding dir\src. and dir\src.. to Additional Include Directories under properties->C/C++->General. Where dir is the directory where the source and build is. I don't know why I had to add this though.

通过添加dir \ src解决了这个问题。和dir \ src ..到属性 - > C / C ++ - >常规下的附加包含目录。其中dir是源和构建所在的目录。我不知道为什么我不得不添加这个。

#1


0  

The problem was solved by adding dir\src. and dir\src.. to Additional Include Directories under properties->C/C++->General. Where dir is the directory where the source and build is. I don't know why I had to add this though.

通过添加dir \ src解决了这个问题。和dir \ src ..到属性 - > C / C ++ - >常规下的附加包含目录。其中dir是源和构建所在的目录。我不知道为什么我不得不添加这个。