Closed SpaceIm closed 4 years ago
@SpaceIm , I fixed the issue. You can look at it in https://github.com/hosseinmoein/DataFrame/commit/d5eb0a8ba0a4748135563fe7f7e9fd6bc005745e thanks HM
@hosseinmoein In this modification, you didn't add any condition based on BUILD_SHARED_LIBS
. For static buid, HMDF_SHARED
must not be defined (and it doesn't really matter for LIBRARY_EXPORTS
).
Moreover, add_definitions
is old CMake, prefer target_compile_definitions
(PRIVATE for LIBRARY_EXPORTS
because you don't want that users define this one at consume time, and PUBLIC for HMDF_SHARED
).
Something like:
if(BUILD_SHARED_LIBS)
target_compile_definitions(${LIBRARY_TARGET_NAME} PRIVATE LIBRARY_EXPORTS PUBLIC HMDF_SHARED)
endif()
@SpaceIm , The problem is I don't have access to a windows development environment and have to rely on Appveyor which is almost impossible to resolve things. But it seems that the DataFrame code would not work in static windows compilation. I get a lot of errors when compiling DateTime.cc and .h. That is why I left the compilation to be shared unconditionally.
DataFrame
is more or less broken if static because it unconditionally adds dllexport/dllimport attributes.For example this macro -found in
VectorPtrView.h
- is wrong for a static lib in Visual Studio:It should be something like this:
If shared:
LIBRARY_EXPORTS
andDATAFRAME_SHARED
definedDATAFRAME_SHARED
definedIf static: no definition at build and consume time
A better approach would be to rely on
generate_export_header
cmake function: https://cmake.org/cmake/help/v3.0/module/GenerateExportHeader.html Therefore you would also be able to properly hide symbols with GNU compilers for shared lib.