Linking to NatNetLib with MinGW

NatNet, VRPN, TrackD, and Plugins
Post Reply
lorneschultz
Posts: 1
Joined: Thu Nov 26, 2015 2:34 pm

Linking to NatNetLib with MinGW

Post by lorneschultz »

I'm cross-compiling an application for Windows from Ubuntu which is based off of the 'SampleClient' application from NatNet_SDK_2.9.

Unfortunately the MinGW cross-compiler can't link against the 'NatNetLib.dll' due to the c++ name-mangling which occurs. Is it possible to get a '.def' or a '.lib/.dll' combo which can be linked-against using MinGW?


build cmd:
i686-mingw32-g++ -o test.exe src/OptitrackClient.cpp -Llib -lNatNetLib

error example from linker fail:
undefined reference to `NatNetClient::SendMessageAndWait(char*, void**, int*)'


I've tried building with MinGW in windows as well with the same results. (Also tried linking against NatNetLibStatic.lib to no avail)
steven.andrews
NaturalPoint Employee
NaturalPoint Employee
Posts: 720
Joined: Mon Jan 19, 2015 11:52 am

Re: Linking to NatNetLib with MinGW

Post by steven.andrews »

Hello lorneschultz,

Since NatNet API is a C++ API, name mangling is inevitable. There is no ABI for C++, so libs created with VisualStudio will not be compatible with MinGW/GCC. Even if name mangling were not an issue, there could be run-time issue due to the different runtime's memory access, class layout or any number of things.

Our initial research suggests that this is not something that will work.
http://www.mingw.org/wiki/Interoperabil ... ler_Brands


An immediate alternative would be to not use the NatNet library, but decode packets directly, using either the UDP depacketize sample or the XML streamer (Unity Sample) samples form the NatNet SDK as examples.

I hope you find this information to be useful. If you require any further assistance, please feel free to open a support ticket with us at help.naturalpoint.com

Best regards,
Steven
--
Steven Andrews
OptiTrack | Customer Support Engineer
Post Reply