1--- a/src/google/protobuf/stubs/port.h 2+++ b/src/google/protobuf/stubs/port.h 3@@ -90,18 +90,31 @@ 4 5 // Legacy: some users reference these (internal-only) macros even though we 6 // don't need them any more. 7-#if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS) 8- #ifdef LIBPROTOBUF_EXPORTS 9- #define LIBPROTOBUF_EXPORT __declspec(dllexport) 10- #else 11- #define LIBPROTOBUF_EXPORT __declspec(dllimport) 12+#if defined(COMPONENT_BUILD) && defined(PROTOBUF_USE_DLLS) 13+ #if defined(_MSC_VER) 14+ #ifdef LIBPROTOBUF_EXPORTS 15+ #define LIBPROTOBUF_EXPORT __declspec(dllexport) 16+ #else 17+ #define LIBPROTOBUF_EXPORT __declspec(dllimport) 18+ #endif 19+ #ifdef LIBPROTOC_EXPORTS 20+ #define LIBPROTOC_EXPORT __declspec(dllexport) 21+ #else 22+ #define LIBPROTOC_EXPORT __declspec(dllimport) 23+ #endif 24+ #else // defined(_MSC_VER) 25+ #ifdef LIBPROTOBUF_EXPORTS 26+ #define LIBPROTOBUF_EXPORT __attribute__((visibility("default"))) 27+ #else 28+ #define LIBPROTOBUF_EXPORT 29+ #endif 30+ #ifdef LIBPROTOC_EXPORTS 31+ #define LIBPROTOC_EXPORT __attribute__((visibility("default"))) 32+ #else 33+ #define LIBPROTOC_EXPORT 34+ #endif 35 #endif 36- #ifdef LIBPROTOC_EXPORTS 37- #define LIBPROTOC_EXPORT __declspec(dllexport) 38- #else 39- #define LIBPROTOC_EXPORT __declspec(dllimport) 40- #endif 41-#else 42+#else // defined(COMPONENT_BUILD) && defined(PROTOBUF_USE_DLLS) 43 #define LIBPROTOBUF_EXPORT 44 #define LIBPROTOC_EXPORT 45 #endif 46