summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2026-11-25 15:23:03 +0100
committerGravatar Nikias Bassen2026-11-25 15:23:03 +0100
commit2b5bbb8966e240fa352ef0ec09bef84d0507c8ea (patch)
tree44b8f502b50a5d800cb492deef18b823eb6b8c95 /src
parent1498dee3aadf66dbae10e699d71c62b428a511a3 (diff)
downloadlibusbmuxd-2b5bbb8966e240fa352ef0ec09bef84d0507c8ea.tar.gz
libusbmuxd-2b5bbb8966e240fa352ef0ec09bef84d0507c8ea.tar.bz2
Windows: Don't use dllimport; only apply dllexport to DLL objects
Public headers declared the API macro as __declspec(dllimport) on Windows unless *_STATIC was defined. That made consumers reference __imp_<symbol>, which only exists in the DLL import library, so linking against the static library failed unless the consumer also defined *_STATIC. All exported symbols are functions, so dllimport is not needed: calls to plain symbols link against both the static library and the import library (via its thunks). Drop it from the public headers. On the library side, apply __declspec(dllexport) only when libtool defines DLL_EXPORT, i.e. when compiling the objects for the DLL. This keeps export directives out of the objects that go into the static library when both are built.
Diffstat (limited to 'src')
-rw-r--r--src/libusbmuxd.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libusbmuxd.c b/src/libusbmuxd.c
index 645fdcf..081f4be 100644
--- a/src/libusbmuxd.c
+++ b/src/libusbmuxd.c
@@ -32,7 +32,11 @@
#ifdef LIBUSBMUXD_STATIC
#define USBMUXD_API
#elif defined(_WIN32)
- #define USBMUXD_API __declspec( dllexport )
+ #ifdef DLL_EXPORT
+ #define USBMUXD_API __declspec( dllexport )
+ #else
+ #define USBMUXD_API
+ #endif
#else
#if __GNUC__ >= 4
#define USBMUXD_API __attribute__((visibility("default")))