Skip to content

Commit 6b8f6b1

Browse files
Compile liblsl on Windows with MinGW
lsl library compiles on Windows 7 with MinGW32, both for dynamic and static versions. Static version also compiles with Visual C++ (tested with Visual Studio 2015).
1 parent 48d1eea commit 6b8f6b1

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

include/lsl_c.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,18 @@
1818
* this header. Under Visual Studio the library is linked in automatically.
1919
*/
2020

21-
#ifdef _WIN32
22-
#ifdef LIBLSL_EXPORTS
21+
#ifdef __MINGW32__
22+
#ifdef LIBLSL_STATIC
23+
#define LIBLSL_C_API
24+
#elif defined (LIBLSL_EXPORTS)
25+
#define LIBLSL_C_API __declspec(dllexport)
26+
#else
27+
#define LIBLSL_C_API __declspec(dllimport)
28+
#endif
29+
#elif defined (_WIN32)
30+
#ifdef LIBLSL_STATIC
31+
#define LIBLSL_C_API
32+
#elif defined (LIBLSL_EXPORTS)
2333
#define LIBLSL_C_API __declspec(dllexport)
2434
#else
2535
#ifndef _DEBUG

src/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ message (${Boost_LIBRARIES})
3333

3434
if (BUILD_SHARED)
3535
add_library (lsl SHARED ${sources})
36-
36+
3737
# TODO: Need to check if all flags are necessary or if some flags are missing
3838
if (WIN32)
3939
set_property (TARGET lsl PROPERTY COMPILE_DEFINITIONS BOOST_ALL_NO_LIB BOOST_THREAD_BUILD_LIB LIBLSL_EXPORTS _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS)
40-
target_link_libraries (lsl ${Boost_LIBRARIES})
40+
if (MINGW)
41+
target_link_libraries (lsl ${Boost_LIBRARIES} winmm ws2_32 wsock32)
42+
else ()
43+
target_link_libraries (lsl ${Boost_LIBRARIES})
44+
endif ()
4145
elseif (APPLE)
4246
target_link_libraries (lsl ${Boost_LIBRARIES} pthread)
4347
elseif (UNIX)
@@ -59,7 +63,8 @@ endif (BUILD_SHARED)
5963

6064
if (BUILD_STATIC)
6165
add_library (lsl-static STATIC ${sources})
62-
66+
set_property (TARGET lsl-static PROPERTY COMPILE_DEFINITIONS LIBLSL_STATIC)
67+
6368
# TODO: Need to check if all flags are necessary or if some flags are missing
6469
# TODO: Add support for other platforms
6570
if (UNIX)

0 commit comments

Comments
 (0)