Opennurbs 6 linking problems


(James Shisley) #1

I’m getting linker errors from new opennurbs library, does anyone know what my project might be missing?

1> Creating library x64\Debug\OpenNurbs.lib and object x64\Debug\OpenNurbs.exp
1>GCOpenNurbs.obj : error LNK2019: unresolved external symbol “public: class ON_ModelGeometryComponent __cdecl ONX_Model::ModelGeometryFromUnsignedIndex(unsigned int)” (?ModelGeometryFromUnsignedIndex@ONX_Model@@QEAA?AVON_ModelGeometryComponent@@I@Z) referenced in function “int __cdecl cb_import_open_nurbs(char *)” (?cb_import_open_nurbs@@YAHPEAD@Z)
1>GCOpenNurbs.obj : error LNK2001: unresolved external symbol “public: static class ON_Interval const ON_Interval::ZeroToTwoPi” (?ZeroToTwoPi@ON_Interval@@2V1@B)
1>GCOpenNurbs.obj : error LNK2001: unresolved external symbol “public: static class ON_Plane const ON_Plane::World_xy” (?World_xy@ON_Plane@@2V1@B)
1>x64\Debug\GCOpenNurbs.dll : fatal error LNK1120: 3 unresolved externals

Thanks.


(Dale Fugier) #2

Hi @james.shisley,

I just downloaded the latest opennurbs, opened the opennurbs_public.sln in Visual Studio 2017, and built the solution in all configurations and platforms without warning or error. So in order to be helpful, we are going to need more information. For example, what compiler are you using, etc.?

Thanks,

– Dale


(James Shisley) #3

Visual Studio Enterprise 2017. The Opennurbs public solution builds fine, it’s trying to use the opennurbs_public.lib that has these linking errors. If I switch to try to use the opennurbs_public_staticlib.lib then it only has the first function link error, ModelGeometryFromUnsignedIndex is missing. I also tried to use ModelGeometryFromIndex instead, but link says that is missing too. I can’t find this used in any example. We also use similar LayerFromIndex it looks like it found that okay.


(James Shisley) #4

If you use the example_convert in that project and change the cpp file, add the line —
ON_ModelGeometryComponent mg = model.ModelGeometryFromUnsignedIndex(0);
right after if has the message dump->Print(“Successfully read.\n”); , try to rebuild that project and it won’t link. It compiles fine, so that function is defined? But it won’t link.


(James Shisley) #5

If you search for it, the only place it finds it is in the header.
D:\Opennurbs_6_1_18014_22401\opennurbs_extensions.h(1252): ON_ModelGeometryComponent ModelGeometryFromUnsignedIndex(
It looks like implementation is missing.

If you search for some of the other similar functions, DimensionStyleFromIndex for example, it finds it, in heade and implementation,
D:\Opennurbs_6_1_18014_22401\opennurbs_extensions.cpp(793):ON_ModelComponentReference ONX_Model::DimensionStyleFromIndex(
D:\Opennurbs_6_1_18014_22401\opennurbs_extensions.h(1158): ON_ModelComponentReference DimensionStyleFromIndex(

It looks like things are missing.


(Dale Fugier) #6

Hi @james.shisley,

I’ve confirmed what you’ve found, and I’ve reported it.

https://mcneel.myjetbrains.com/youtrack/issue/RH-43803

Note, openNURBS has a new component iterator. So the above missing defintion isn’t necessary to use openNURBS.

For example:

...

ONX_ModelComponentIterator it(model, ON_ModelComponent::Type::ModelGeometry);
const ON_ModelComponent* model_component = nullptr;
for (model_component = it.FirstComponent(); nullptr != model_component; model_component = it.NextComponent())
{
  const ON_ModelGeometryComponent* model_geometry = ON_ModelGeometryComponent::Cast(model_component);
  if (nullptr != model_geometry)
  {
    const ON_Mesh* mesh = ON_Mesh::Cast(model_geometry->Geometry(nullptr));
    if (nullptr != mesh)
    {
      // TODO...
    }
  }
}

– Dale


(James Shisley) #7

Okay, it looks like I can change it to use that. I’m still missing the global objects trying to use the dll library,
1> Creating library x64\Debug\OpenNurbs.lib and object x64\Debug\OpenNurbs.exp
1>GCOpenNurbs.obj : error LNK2001: unresolved external symbol “public: static class ON_Interval const ON_Interval::ZeroToTwoPi” (?ZeroToTwoPi@ON_Interval@@2V1@B)
1>GCOpenNurbs.obj : error LNK2001: unresolved external symbol “public: static class ON_Plane const ON_Plane::World_xy” (?World_xy@ON_Plane@@2V1@B)
1>x64\Debug\GCOpenNurbs.dll : fatal error LNK1120: 2 unresolved externals

Any ideas about those?


(James Shisley) #8

But it looks like maybe I can use the staticlib.lib instead, I got that to link.


(Dale Fugier) #9

Hi James,

ON_Interval::ZeroToTwoPi is a const static declared in opennurbs_point.h and defined in opennurbs_statics.cpp.

ON_Plane::World_xy is a const static declared in opennurbs_plane and (also) defined in opennurbs_statics.cpp.

I’m not sure why you’re getting the unresolved externals during linking.

– Dale