OpenNURBS linking problems

Good afternoon,
I’m a new user of OpenNURBS, and I’m having problems when statically linking it to another C++ project in Visual Studio 2010. To explain from the start, I should mention I downloaded the C++ OpenNURBS SDK and compiled it fine according to the instructions. After that, I linked it to my project the usual way:

  1. In the C/C++ -> General -> Additional Include Directories section, I added the path to the header files folder, which is the base folder of the downloaded bundle.
  2. In the Linker -> General -> Additional Library Directories section, I added the path to the Release and ReleaseStaticLib folders, both generated when I compiled the SDK, and the zlib\Release folder.
  3. In the Linker -> Input -> Additional Dependencies section, I added the three library names: opennurbs.lib, opennurbs_staticlib.lib and zlib.lib (all of them in the Release folder).

After adding the “#include <opennurbs.h>” suggested by the license to my code, everything seems to be fine, no red lines, but when I try to build my project, the linker always comes out with a “LNK2019 error: unable to find external symbol” error for every constructor, destructor and any other OpenNURBS function called in my code. What I get from that is that Visual Studio is unable to find the function’s body, but does find the declarations in the header files, since otherwise I’d had lots of red lines in my source code. The only reason I can think of is that it has problems with the library files.

I did notice the library file “opennurbs_staticlib.lib” file was located in the “Release” folder instead of “ReleaseStaticLib”. I tried moving it there, but it made no difference.

I’d be grateful if someone would be able to tell me which step I missed or if I messed up somewhere in the process, OpenNURBS has a lot of useful functions that would be very helpful in my project.

I think you should only add the opennurbs_static.lib, not the opennurbs.lib as additional dependency. The latter is for dynamic linking to a shared library. Oh, and zlib.lib too.

To use a static version of openNURBS, you only need to build the zlib and opennurbs_staticlib projects (found in the solution). Then, link with opennurbs_static.lib and zlib.lib.

Thank you for your answers. I rebuilt the opennurbs_staticlib and zlib projects, just in case, and then deleted the reference to opennurbs.lib file, just leaving the other two. Unfortunately, the error seems to be persisting. I’ll copy the error here and the code snippet that produces it in case it helps.

The code is as shown below. The onPunto() function is a self-made one to transform the point structure I use into ON_3dPoint points for use with OpenNURBS.

ON_Sphere esfera = ON_Sphere(onPunto(puntosLejanos[0]), 2.0);

That single line produces the following errors:

Error 31 error LNK2019: símbolo externo “public: __cdecl ON_Sphere::~ON_Sphere(void)” (??1ON_Sphere@@QEAA@XZ) sin resolver al que se hace referencia en la función main X:\[…]\New\pcl_visualiz.obj pcl_visualiz

Error 37 error LNK2019: símbolo externo “public: __cdecl ON_Sphere::ON_Sphere(class ON_3dPoint const &,double)” (??0ON_Sphere@@QEAA@AEBVON_3dPoint@@N@Z) sin resolver al que se hace referencia en la función main X:\[…]\New\pcl_visualiz.obj pcl_visualiz

A tentative translation would be: LNK2019 error: unresolved external symbol “public: __cdecl ON_Sphere::ON_Sphere(class ON_3dPoint const &,double)” (??0ON_Sphere@@QEAA@AEBVON_3dPoint@@N@Z) referenced by function main X:\[…]\New\pcl_visualiz.obj pcl_visualiz

As I understand it, either Visual Studio fails to load the library or the library doesn’t have the correct path to the classes. Maybe I didn’t build it right, but I don’t think I did anything strange. VS doesn’t seem to have problems finding the header files, though, and I’m sure it does find the library files; I’ve tried, and an incorrect file path results in another error.

Why not just do this:

ON_Sphere sphere(point, radius);

// or...

ON_Sphere esfera(onPunto(puntosLejanos[0]), 2.0);