I need some help on writing cross-platform code; not an application, but a library.
I am creating a library both static and dynamic with most of the development done
Maybe it's better if you Add extern "C" !!!,
/* file CMakeLists.txt */
SET (LIB_TYPE SHARED)
ADD_LIBRARY(MyLibrary ${LIB_TYPE} MyLibrary.h)
/* file MyLibrary.h */
#if defined(_WIN32) || defined(__WIN32__)
# if defined(MyLibrary_EXPORTS) // add by CMake
# define MYLIB_EXPORT extern "C" __declspec(dllexport)
# else
# define MYLIB_EXPORT extern "C" __declspec(dllimport)
# endif // MyLibrary_EXPORTS
#elif defined(linux) || defined(__linux)
# define MYLIB_EXPORT
#endif
MYLIB_EXPORT inline int Function(int a) {
return a;
}