This is an automated email from the ASF dual-hosted git repository. jking pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push: new 8fdb758 THRIFT-4759:add thrift export to fix windows shared lib building (#1714) 8fdb758 is described below commit 8fdb7587e688ae66a0e30e9f22bf8dc09599b2e9 Author: cyy <cyye...@outlook.com> AuthorDate: Tue Feb 5 02:57:21 2019 +0800 THRIFT-4759:add thrift export to fix windows shared lib building (#1714) * add THRIFT_EXPORT to fix windows shared lib building * use shared libraries on vs2017 appveyor build, leave msvc2017 static link --- appveyor.yml | 2 +- lib/cpp/CMakeLists.txt | 4 ++++ lib/cpp/Makefile.am | 1 + lib/cpp/src/thrift/TOutput.cpp | 2 +- lib/cpp/src/thrift/TOutput.h | 4 +++- lib/cpp/src/thrift/thrift_export.h | 20 ++++++++++++++++++++ lib/cpp/src/thrift/transport/TSSLServerSocket.cpp | 1 + lib/cpp/src/thrift/transport/TSSLSocket.h | 2 +- 8 files changed, 32 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 39aba4f..74c92f1 100755 --- a/appveyor.yml +++ b/appveyor.yml @@ -39,7 +39,7 @@ environment: - PROFILE: MSVC2017 PLATFORM: x64 CONFIGURATION: Release - BUILD_SHARED_LIBS: OFF + BUILD_SHARED_LIBS: ON BOOST_VERSION: 1.67.0 LIBEVENT_VERSION: 2.1.8 PYTHON_VERSION: 3.6 diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index dd90c80..e92da60 100755 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -23,6 +23,10 @@ REQUIRE_BOOST_HEADERS() include_directories(src) +if(NOT BUILD_SHARED_LIBS) + add_definitions("-DTHRIFT_STATIC_DEFINE") +endif() + # SYSLIBS contains libraries that need to be linked to all lib targets set(SYSLIBS "") diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am index 616effd..114ff17 100755 --- a/lib/cpp/Makefile.am +++ b/lib/cpp/Makefile.am @@ -132,6 +132,7 @@ include_thriftdir = $(includedir)/thrift include_thrift_HEADERS = \ $(top_builddir)/config.h \ src/thrift/thrift-config.h \ + src/thrift/thrift_export.h \ src/thrift/TDispatchProcessor.h \ src/thrift/Thrift.h \ src/thrift/TOutput.h \ diff --git a/lib/cpp/src/thrift/TOutput.cpp b/lib/cpp/src/thrift/TOutput.cpp index f25b566..8d163a9 100644 --- a/lib/cpp/src/thrift/TOutput.cpp +++ b/lib/cpp/src/thrift/TOutput.cpp @@ -27,7 +27,7 @@ namespace apache { namespace thrift { -TOutput GlobalOutput; +THRIFT_EXPORT TOutput GlobalOutput; TOutput::TOutput() : f_(&errorTimeWrapper) {} diff --git a/lib/cpp/src/thrift/TOutput.h b/lib/cpp/src/thrift/TOutput.h index 6135cfa..26c9a56 100644 --- a/lib/cpp/src/thrift/TOutput.h +++ b/lib/cpp/src/thrift/TOutput.h @@ -20,6 +20,8 @@ #ifndef _THRIFT_OUTPUT_H_ #define _THRIFT_OUTPUT_H_ 1 +#include <thrift/thrift_export.h> + namespace apache { namespace thrift { @@ -51,7 +53,7 @@ private: void (*f_)(const char*); }; -extern TOutput GlobalOutput; +THRIFT_EXPORT extern TOutput GlobalOutput; } } // namespace apache::thrift diff --git a/lib/cpp/src/thrift/thrift_export.h b/lib/cpp/src/thrift/thrift_export.h new file mode 100644 index 0000000..f5c059f --- /dev/null +++ b/lib/cpp/src/thrift/thrift_export.h @@ -0,0 +1,20 @@ +#ifndef THRIFT_EXPORT_H +#define THRIFT_EXPORT_H + +#ifdef THRIFT_STATIC_DEFINE +# define THRIFT_EXPORT +#elif defined(_MSC_VER ) +# ifndef THRIFT_EXPORT +# ifdef thrift_EXPORTS + /* We are building this library */ +# define THRIFT_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define THRIFT_EXPORT __declspec(dllimport) +# endif +# endif +#else +# define THRIFT_EXPORT +#endif + +#endif /* THRIFT_EXPORT_H */ diff --git a/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp b/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp index 34605c0..b20c174 100644 --- a/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp +++ b/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp @@ -17,6 +17,7 @@ * under the License. */ +#include <thrift/thrift_export.h> #include <thrift/transport/TSSLServerSocket.h> #include <thrift/transport/TSSLSocket.h> diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.h b/lib/cpp/src/thrift/transport/TSSLSocket.h index 8f095dc..4d46998 100644 --- a/lib/cpp/src/thrift/transport/TSSLSocket.h +++ b/lib/cpp/src/thrift/transport/TSSLSocket.h @@ -321,7 +321,7 @@ private: std::shared_ptr<AccessManager> access_; static concurrency::Mutex mutex_; static uint64_t count_; - static bool manualOpenSSLInitialization_; + THRIFT_EXPORT static bool manualOpenSSLInitialization_; void setup(std::shared_ptr<TSSLSocket> ssl); static int passwordCallback(char* password, int size, int, void* data); };