0

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.

  • Did you select "shared libs" in CMake? If so, you have to carry the dlls to the new project – Kev1n91 Sep 27 '17 at 11:37
  • @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 Sep 27 '17 at 12:02
  • @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 Sep 27 '17 at 12:10
  • in the CMake Gui is a checkbox "Advanced" then you should see the checkbox for the shared library – Kev1n91 Sep 27 '17 at 12:20
  • The problem was solved by adding \src\. and \src\.. to Additional Include Directories under properties->C/C++->General. Where is the directory where the source and build is. I don't know why I had to add this. – Zain Hassan Oct 06 '17 at 11:59
  • You can answer your question if you like and mark it as answered – Kev1n91 Oct 08 '17 at 13:10
  • Although it was solved, it sounds like a somewhat unusual way to resolve that. Question, did you add the library directories to `LD_LIBRARY_PATH`? (Probably along with the library directories of TBB and OpenEXR) – Aziuth Jan 04 '18 at 13:46
  • @Aziuth I may have misunderstood your comment. I believe `LD_LIBRARY_PATH` is an environment variable in Linux but my project is in Windows (Visual Studio 2013). However, I didn't add path of any library to environment variables; instead I used CMake to set include paths using `INCLUDE_DIRECTORIES` (which adds path to Properties->C++->General->Additional Include Directories in VS) and linked libraries using `TARGET_LINK_LIBRARIES` (which add libraries to Linker->Input->Additional Dependencies in VS) – Zain Hassan Jan 05 '18 at 15:33
  • @ZainHassan My comment might be plainly wrong for your case. Thing is, I also had trouble compiling openvdb, but I did it under linux, using qmake, so my troubles are probably different. I had added the library file and the headers in my qmake project file, but it did not worked out for some missing symbols, until I changed that environment variable. Which I thought was somewhat counter intuitive. Might not be relevant for your case, but some additional input can't hurt. – Aziuth Jan 05 '18 at 20:34

1 Answers1

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.