C++ linker warnings regarding ON_SimpleArray

Hi,

I’m getting a lot of linker warnings because of multiple definitions for various types of ON_SimpleArrays, this is an example with ON_SimpleArray<ON_3dPoint>:

Warning 30 warning LNK4006: “public: virtual __cdecl ON_SimpleArray::~ON_SimpleArray(void)” (??1?$ON_SimpleArray@VON_3dPoint@@@@UEAA@XZ) already defined in “opennurbsx64.lib(opennurbsx64.dll)”; ignoring second definiton… (path to .lib containing second definition)

This happens when linking a plugin against Rhino and a static library that makes use of OpenNURBS as well (but as it is a static library, I don’t understand where the 2nd definitions are coming from). Does someone have any idea how to prevent this?

Best regards,
Alex

Hi Alex,

Is this still an issue? Sorry for missing it…

– Dale

Hi Dale, no problem, yes it’s still an issue. I have had this warnings for a long time, tried to find a way to resolve, unsuccessfully. Any hints would be great. Cheers, Alex

Statically linking in a library that is referencing a different version of another library you are using in your plug-in is a really bad idea. Is this static library yours? If so, then I could add the static library project to your plug-in solution, and then modify the static library to use the same openNURBS (DLL) as your plug-in (conditionally of course).

Hi Dale, many thanks for your reply. The static library is ours, and it includes exactly the same header files from the Rhino (4 or 5) SDK as our plugins do. That’s why I don’t understand the warning messages, because there shouldn’t be any double definitions.

The functions and variables in your static library, referenced by your plug-in, are copied into your plug-in DLL by the linker as it resolves the referenced symbols. Since the linker already knows about the version of ON_SimpleArray provided the openNURBS DLL (for example), it complains about the duplicate in the static library. The linker is not complaining about the duplicate definition, its complaining about the duplicate class, in this case.

Like I said, your plug-in and your static lib should link with the same openNURBS when your static lib is used by your plug-in.