0
votes

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.

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,

it throws a linker error 'LNK2019: unresolved external symbols "void_cdecl openvdb::v3_0_0::initialize(void)" referenced in function 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.

Thank you for the help.

1
Did you select "shared libs" in CMake? If so, you have to carry the dlls to the new project - Kev1n91
@Kev1n91 Thank you for comment. All the dlls are present in the folder where the executable is supposed to be, it is done by a post_copy macro already present in cmakelists.txt. There is no option to select shared library. Is it supposed to be in cmake GUI? or should I write it in cmake file? Can you elaborate please - Zain Hassan
@Kev1n91 Just to add to my previous comment: For each library I add the *.lib files using "target_link_libraries" and add the include directories using "include_directories" in cmake files. From the cmake GUI I make sure that *.lib files for every library are found. For example after configuring I get "OpenVDB Library: Found at */OpenVDB/lib/openvdb.lib" And I also check it's presence in the project properties in VS. - Zain Hassan
in the CMake Gui is a checkbox "Advanced" then you should see the checkbox for the shared library - Kev1n91
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. - Zain Hassan

1 Answers

0
votes

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.