[
https://issues.apache.org/jira/browse/ARROW-1723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16221620#comment-16221620
]
ASF GitHub Bot commented on ARROW-1723:
---------------------------------------
wesm closed pull request #1244: ARROW-1723: [C++] add ARROW_STATIC to mark
static libs on Windows
URL: https://github.com/apache/arrow/pull/1244
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/cpp/README.md b/cpp/README.md
index 9c2684235..60383535b 100644
--- a/cpp/README.md
+++ b/cpp/README.md
@@ -69,6 +69,14 @@ Simple release build:
Detailed unit test logs will be placed in the build directory under
`build/test-logs`.
+### Statically linking to Arrow on Windows
+
+The Arrow headers on Windows static library builds (enabled by the CMake
+option `ARROW_BUILD_STATIC`) use the preprocessor macro `ARROW_STATIC` to
+suppress dllimport/dllexport marking of symbols. Projects that statically link
+against Arrow on Windows additionally need this definition. The Unix builds do
+not use the macro.
+
### Building/Running benchmarks
Follow the directions for simple build except run cmake
diff --git a/cpp/cmake_modules/BuildUtils.cmake
b/cpp/cmake_modules/BuildUtils.cmake
index fb09e4e95..207bb9aed 100644
--- a/cpp/cmake_modules/BuildUtils.cmake
+++ b/cpp/cmake_modules/BuildUtils.cmake
@@ -98,21 +98,28 @@ function(ADD_ARROW_LIB LIB_NAME)
message(SEND_ERROR "Error: unrecognized arguments:
${ARG_UNPARSED_ARGUMENTS}")
endif()
- add_library(${LIB_NAME}_objlib OBJECT
- ${ARG_SOURCES}
- )
-
- if (ARG_DEPENDENCIES)
- add_dependencies(${LIB_NAME}_objlib ${ARG_DEPENDENCIES})
+ if(MSVC)
+ set(LIB_DEPS ${ARG_SOURCES})
+ set(EXTRA_DEPS ${ARG_DEPENDENCIES})
+ else()
+ add_library(${LIB_NAME}_objlib OBJECT
+ ${ARG_SOURCES})
+ # Necessary to make static linking into other shared libraries work
properly
+ set_property(TARGET ${LIB_NAME}_objlib PROPERTY POSITION_INDEPENDENT_CODE
1)
+ if (ARG_DEPENDENCIES)
+ add_dependencies(${LIB_NAME}_objlib ${ARG_DEPENDENCIES})
+ endif()
+ set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ set(EXTRA_DEPS)
endif()
- # Necessary to make static linking into other shared libraries work properly
- set_property(TARGET ${LIB_NAME}_objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
-
set(RUNTIME_INSTALL_DIR bin)
if (ARROW_BUILD_SHARED)
- add_library(${LIB_NAME}_shared SHARED $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ add_library(${LIB_NAME}_shared SHARED ${LIB_DEPS})
+ if (EXTRA_DEPS)
+ add_dependencies(${LIB_NAME}_shared ${EXTRA_DEPS})
+ endif()
if(APPLE)
# On OS X, you can avoid linking at library load time and instead
@@ -154,22 +161,28 @@ function(ADD_ARROW_LIB LIB_NAME)
endif()
if (ARROW_BUILD_STATIC)
- if (MSVC)
- set(LIB_NAME_STATIC ${LIB_NAME}_static)
- else()
- set(LIB_NAME_STATIC ${LIB_NAME})
- endif()
- add_library(${LIB_NAME}_static STATIC
$<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ add_library(${LIB_NAME}_static STATIC ${LIB_DEPS})
+ if(EXTRA_DEPS)
+ add_dependencies(${LIB_NAME}_static ${EXTRA_DEPS})
+ endif()
+
+ if (MSVC)
+ set(LIB_NAME_STATIC ${LIB_NAME}_static)
+ target_compile_definitions(${LIB_NAME}_static PUBLIC ARROW_STATIC)
+ else()
+ set(LIB_NAME_STATIC ${LIB_NAME})
+ endif()
+
set_target_properties(${LIB_NAME}_static
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}"
OUTPUT_NAME ${LIB_NAME_STATIC})
- target_link_libraries(${LIB_NAME}_static
+ target_link_libraries(${LIB_NAME}_static
LINK_PUBLIC ${ARG_STATIC_LINK_LIBS}
LINK_PRIVATE ${ARG_STATIC_PRIVATE_LINK_LIBS})
- install(TARGETS ${LIB_NAME}_static
+ install(TARGETS ${LIB_NAME}_static
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/cpp/src/arrow/util/visibility.h b/cpp/src/arrow/util/visibility.h
index ea78e5720..119c55df3 100644
--- a/cpp/src/arrow/util/visibility.h
+++ b/cpp/src/arrow/util/visibility.h
@@ -25,7 +25,9 @@
#pragma GCC diagnostic ignored "-Wattributes"
#endif
-#ifdef ARROW_EXPORTING
+#ifdef ARROW_STATIC
+#define ARROW_EXPORT
+#elif defined(ARROW_EXPORTING)
#define ARROW_EXPORT __declspec(dllexport)
#else
#define ARROW_EXPORT __declspec(dllimport)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Windows: __declspec(dllexport) specified when building arrow static library
> ---------------------------------------------------------------------------
>
> Key: ARROW-1723
> URL: https://issues.apache.org/jira/browse/ARROW-1723
> Project: Apache Arrow
> Issue Type: Bug
> Components: C++
> Reporter: John Jenkins
> Labels: pull-request-available
> Fix For: 0.8.0
>
>
> As I understand it, dllexport/dllimport should be left out when building and
> using static libraries on Windows. A PR will follow shortly.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)