-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
Description
Currently you are getting following compile issue under windows in case you have BUILD_surface_on_nurbs enabled:
example_nurbs_viewer_surface.obj : error LNK2019: unresolved external symbol ON_ErrorEx referenced in function "public: class ONX_Model_Object & __cdecl ON_ClassArray<class ONX_Model_Object>::operator[](int)" (??A?$ON_ClassArray@VONX_Model_Object@@@@QEAAAEAVONX_Model_Object@@H@Z)
35>
Reason is the missing macro ON_DLL_TEMPLATE, caused by missing macro ON_DLL_EXPORTS
pcl/surface/include/pcl/surface/3rdparty/opennurbs/opennurbs_extensions.h
Lines 139 to 167 in 8eb4768
| #if defined(ON_DLL_TEMPLATE) | |
| // This stuff is here because of a limitation in the way Microsoft | |
| // handles templates and DLLs. See Microsoft's knowledge base | |
| // article ID Q168958 for details. | |
| #pragma warning( push ) | |
| #pragma warning( disable : 4231 ) | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_Bitmap*>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_Linetype>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_Linetype>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_Layer>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_Layer>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_Group>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_Group>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_Font>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_Font>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_DimStyle>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_DimStyle>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ONX_Model_RenderLight>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_HatchPattern>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_HatchPattern>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_InstanceDefinition>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_InstanceDefinition>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ONX_Model_Object>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ONX_Model_UserData>; | |
| ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_HistoryRecord*>; | |
| #pragma warning( pop ) | |
| #endif |
The macro will be defined here:
pcl/surface/include/pcl/surface/3rdparty/opennurbs/opennurbs_defines.h
Lines 88 to 123 in c440618
| #if defined(ON_DLL_EXPORTS) | |
| #if !defined(ON_COMPILING_OPENNURBS) | |
| #error When compiling an OpenNURBS DLL, ON_DLL_EXPORTS must be defined | |
| #endif | |
| /* compiling OpenNurbs as a Windows DLL - export classes, functions, templates, and globals */ | |
| #define ON_CLASS __declspec(dllexport) | |
| #define ON_DECL __declspec(dllexport) | |
| #define ON_EXTERN_DECL __declspec(dllexport) | |
| #define ON_DLL_TEMPLATE | |
| #elif defined(ON_DLL_IMPORTS) | |
| #if defined(ON_COMPILING_OPENNURBS) | |
| #error When compiling an OpenNURBS DLL, ON_DLL_IMPORTS must NOT be defined | |
| #endif | |
| /* using OpenNurbs as a Windows DLL - import classes, functions, templates, and globals */ | |
| #define ON_CLASS __declspec(dllimport) | |
| #define ON_DECL __declspec(dllimport) | |
| #define ON_EXTERN_DECL __declspec(dllimport) | |
| #define ON_DLL_TEMPLATE extern | |
| #else | |
| /* compiling or using OpenNurbs as a static library */ | |
| #define ON_CLASS | |
| #define ON_DECL | |
| #define ON_EXTERN_DECL | |
| #if defined(ON_DLL_TEMPLATE) | |
| #undef ON_DLL_TEMPLATE | |
| #endif | |
| #endif |
To enable this block OPENNURBS_EXPORTS needs to be defined
| #if defined(OPENNURBS_EXPORTS) | |
| // OPENNURBS_EXPORTS is Microsoft's prefered defined for building an opennurbs DLL. | |
| #if !defined(ON_DLL_EXPORTS) | |
| #define ON_DLL_EXPORTS | |
| #endif |
And surprise: OPENNURBS_EXPORTS will be never be defined.
A long time ago there was already a try to fix issues with it, but this fix was incomplete.
So we have the choice:
- Adding
OPENNURBS_EXPORTSflag: In this case we need to exportOPENNURBS_IMPORTS, too and revert the old fix. Otherwise you are getting tons of warnings:warning C4141: 'dllexport': used more than once (compiling source file C:\dev\pcl\surface\src\3rdparty\opennurbs\opennurbs_3dm_attributes.cpp) - Replacing
ON_CLASSand all other openNURBS specific macros by e.g.PCL_EXPORTS. In this case we have currently no replacement for e.g.ON_DLL_TEMPLATE