Closed jhallier closed 3 years ago
Have you tried this with an external example that is not built via qpOASES build system? I am afraid that in that case QPOASES_EXPORT
is not defined, and this would result in a compilation error. Furthermore, are you sure that it is not necessary to mark the symbols as __declspec(dllimport)
in the compilation units that import them?
You mean not building it with CMake? You're right, it would have to be undefined then. In that case, it may be better to define it within the source files, then it can also be undefined for other systems than Windows. I'll have to think about it. Do you have other ideas? For the __declspec(dllimport), I don't believe it is necessary, since the symbols are exported to the accompanying .lib file (which only contains the exported functions from the dll so that the linker can find them).
You mean not building it with CMake?
No, I mean an external project that is using qpOASES, so a completly different project that is finding qpOASES by using a FindqpOASES cmake file such as https://github.com/PositronicsLab/Moby/blob/master/CMakeModules/FindQPOASES.cmake, or simply by directly passing to the compiler the correct include and link flags. In such case, I would expect the compilation to fail as QPOASES_EXPORT
is not defined. The techinque typically use to avoid this is to define such macros not via command line, but using a devoted header that is either manually written (see https://gcc.gnu.org/wiki/Visibility#Step-by-step_guide and https://cmake.org/cmake/help/latest/prop_tgt/DEFINE_SYMBOL.html) or generated by the build system (see https://cmake.org/cmake/help/latest/module/GenerateExportHeader.html).
A macro was added for Windows shared library builds that sets all classes/methods that needs to be exported to a shared library to the directive __declspec(dllexport). If no shared library is build, this macro is replaced with an empty string, i.e. just as it was before. I have tested this with a shared and static build under Windows, and with the internal examples, but I may have missed other methods that are not used in the examples.