Skip to content

Commit bdb3339

Browse files
committed
allow win32 to build shared lib
1 parent 30e95f4 commit bdb3339

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ IF (DISABLE_SHARED)
5151
ADD_LIBRARY (libsolv STATIC ${libsolv_SRCS})
5252
ELSE (DISABLE_SHARED)
5353
ADD_LIBRARY (libsolv SHARED ${libsolv_SRCS})
54+
TARGET_COMPILE_DEFINITIONS(libsolv PRIVATE SOLV_EXPORTS)
5455
ENDIF (DISABLE_SHARED)
5556

5657
SET_TARGET_PROPERTIES(libsolv PROPERTIES OUTPUT_NAME "solv")

win32/config.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifdef _WIN32
2+
#ifdef SOLV_STATIC_LIB
3+
#define SOLV_API
4+
#else
5+
#ifdef SOLV_EXPORTS
6+
#define SOLV_API __declspec(dllexport)
7+
#else
8+
#define SOLV_API __declspec(dllimport)
9+
#endif
10+
#endif
11+
#else
12+
#define SOLV_API
13+
#endif

win32/getopt.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
#include <stdlib.h>
66
#include <stdio.h>
77

8-
char *optarg;
9-
int optind=1, opterr=1, optopt, __optpos, __optreset=0;
8+
#include "config.h"
9+
10+
SOLV_API char *optarg;
11+
SOLV_API int optind=1, opterr=1, optopt, __optpos, __optreset=0;
1012

1113
#define optpos __optpos
1214

win32/getopt.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
extern "C" {
66
#endif
77

8+
#include "config.h"
9+
810
int getopt(int, char * const [], const char *);
9-
extern char *optarg;
10-
extern int optind, opterr, optopt, optreset;
11+
12+
SOLV_API extern char *optarg;
13+
SOLV_API extern int optind, opterr, optopt, optreset;
1114

1215
struct option {
1316
const char *name;

0 commit comments

Comments
 (0)