MinGW build error
When I build the CMake project with MinGW 7.3.0 on Windows then I see the following build error when compiling the examples:
...
[ 52%] Building CXX object CMakeFiles/servoj_example.dir/examples/cpp/servoj_example.cpp.obj
In file included from C:/CodingXP/ur_rtde/include/ur_rtde/rtde_control_interface.h:6:0,
from C:\CodingXP\ur_rtde\examples\cpp\servoj_example.cpp:1:
C:/CodingXP/ur_rtde/include/ur_rtde/rtde.h:106:17: error: function 'ur_rtde::RTDE::RobotCommand::RobotCommand()' definition is marked dllimport
RTDE_EXPORT RobotCommand() : type_(NO_CMD), recipe_id_(1)
^~~~~~~~~~~~
make[2]: *** [CMakeFiles\servoj_example.dir\build.make:63: CMakeFiles/servoj_example.dir/examples/cpp/servoj_example.cpp.obj] Error 1
make[1]: *** [CMakeFiles\Makefile2:112: CMakeFiles/servoj_example.dir/all] Error 2
make: *** [Makefile:129: all] Error 2
I can fix this for me, if I manually add an empty define RTDE_EXPORT
export statement to the generated file rtde_export.h
so that the file looks like this:
#ifndef RTDE_EXPORT_H
#define RTDE_EXPORT_H
#define RTDE_EXPORT
#ifdef RTDE_STATIC_DEFINE
# define RTDE_EXPORT
# define RTDE_NO_EXPORT
#else
# ifndef RTDE_EXPORT
# ifdef rtde_EXPORTS
/* We are building this library */
# define RTDE_EXPORT __declspec(dllexport)
# else
/* We are using this library */
# define RTDE_EXPORT __declspec(dllimport)
# endif
# endif
...
For MinGW builds __declspec(dllimport)
and __declspec(dllexport)
are not required but I'm not a CMake expert and don't know how to fix this properly. Maybe someone knows how to fix this properly for all MinGW users.
Edited by Uwe Kindler