From 8559cb0b68505ded1d7c53dbcb3c0fbcdad60113 Mon Sep 17 00:00:00 2001 From: Airbrett Date: Sat, 1 Oct 2022 07:42:31 -0600 Subject: [PATCH 1/4] fix dllexport/import for MSVC dll --- include/chipmunk/chipmunk.h | 8 ++++++++ src/CMakeLists.txt | 2 ++ 2 files changed, 10 insertions(+) diff --git a/include/chipmunk/chipmunk.h b/include/chipmunk/chipmunk.h index d98ba7ea..a008fe34 100644 --- a/include/chipmunk/chipmunk.h +++ b/include/chipmunk/chipmunk.h @@ -36,7 +36,15 @@ #endif #ifdef _WIN32 + #ifdef CHIPMUNK_SHARED + #ifdef CHIPMUNK_BUILD #define CP_EXPORT __declspec(dllexport) +#else + #define CP_EXPORT __declspec(dllimport) + #endif + #else + #define CP_EXPORT + #endif #else #define CP_EXPORT #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34882d14..8fc247aa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,8 @@ if(BUILD_SHARED) if(MSVC) set_source_files_properties(${chipmunk_source_files} PROPERTIES LANGUAGE CXX) set_target_properties(chipmunk PROPERTIES LINKER_LANGUAGE CXX) + target_compile_options(chipmunk PRIVATE CHIPMUNK_BUILD + PUBLIC CHIPMUNK_SHARED) endif(MSVC) # set the lib's version number # But avoid on Android because symlinks to version numbered .so's don't work with Android's Java-side loadLibrary. From e497d2acdaa08a3f39ec4236311bdeb5528d5e03 Mon Sep 17 00:00:00 2001 From: Airbrett Date: Sat, 1 Oct 2022 07:48:41 -0600 Subject: [PATCH 2/4] definitions, not options! --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8fc247aa..eff251d2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,7 +19,7 @@ if(BUILD_SHARED) if(MSVC) set_source_files_properties(${chipmunk_source_files} PROPERTIES LANGUAGE CXX) set_target_properties(chipmunk PROPERTIES LINKER_LANGUAGE CXX) - target_compile_options(chipmunk PRIVATE CHIPMUNK_BUILD + target_compile_definitions(chipmunk PRIVATE CHIPMUNK_BUILD PUBLIC CHIPMUNK_SHARED) endif(MSVC) # set the lib's version number From 60103527f6e69d05b42e373a370a4c63ec279c05 Mon Sep 17 00:00:00 2001 From: Airbrett Date: Sat, 1 Oct 2022 07:49:49 -0600 Subject: [PATCH 3/4] add missing exports --- include/chipmunk/cpRobust.h | 4 ++-- src/cpRobust.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/chipmunk/cpRobust.h b/include/chipmunk/cpRobust.h index e4b2c420..8c0fd362 100644 --- a/include/chipmunk/cpRobust.h +++ b/include/chipmunk/cpRobust.h @@ -5,7 +5,7 @@ // "Fast math" should be disabled here. // Check if c is to the left of segment (a, b). -cpBool cpCheckPointGreater(const cpVect a, const cpVect b, const cpVect c); +CP_EXPORT cpBool cpCheckPointGreater(const cpVect a, const cpVect b, const cpVect c); // Check if p is behind one of v0 or v1 on axis n. -cpBool cpCheckAxis(cpVect v0, cpVect v1, cpVect p, cpVect n); +CP_EXPORT cpBool cpCheckAxis(cpVect v0, cpVect v1, cpVect p, cpVect n); diff --git a/src/cpRobust.c b/src/cpRobust.c index 57507d14..91aa6823 100644 --- a/src/cpRobust.c +++ b/src/cpRobust.c @@ -1,4 +1,4 @@ -#include "chipmunk/cpRobust.h" +#include "chipmunk/chipmunk_private.h" cpBool From 63a23e5edef58406ec4b18ca8f34955f2d7c892a Mon Sep 17 00:00:00 2001 From: Airbrett Date: Sat, 1 Oct 2022 07:50:36 -0600 Subject: [PATCH 4/4] add exports and ensure exports are C mangling --- include/chipmunk/chipmunk.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/chipmunk/chipmunk.h b/include/chipmunk/chipmunk.h index a008fe34..2b06e4bc 100644 --- a/include/chipmunk/chipmunk.h +++ b/include/chipmunk/chipmunk.h @@ -38,8 +38,8 @@ #ifdef _WIN32 #ifdef CHIPMUNK_SHARED #ifdef CHIPMUNK_BUILD - #define CP_EXPORT __declspec(dllexport) -#else + #define CP_EXPORT __declspec(dllexport) + #else #define CP_EXPORT __declspec(dllimport) #endif #else @@ -119,7 +119,10 @@ typedef struct cpArbiter cpArbiter; typedef struct cpSpace cpSpace; #include "cpVect.h" +#include "cpRobust.h" +#include "cpHastySpace.h" #include "cpBB.h" +#include "cpMarch.h" #include "cpTransform.h" #include "cpSpatialIndex.h"