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)
Linking to NatNetLib with MinGW
-
- NaturalPoint Employee
- Posts: 719
- Joined: Mon Jan 19, 2015 11:52 am
Re: Linking to NatNetLib with MinGW
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
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