This repository was archived by the owner on Aug 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +15
-9
lines changed
Expand file tree Collapse file tree 4 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -48,12 +48,14 @@ target_link_libraries(${PROJECT_NAME} nlohmann_json nlohmann_json::nlohmann_json
4848target_link_libraries (${PROJECT_NAME} CURL::libcurl)
4949#target_link_libraries(${PROJECT_NAME} INTERFACE ${BOOST_LIBRARIES})
5050
51- if (MSVC )
52- if (BUILD_SHARED_LIBS )
53- target_compile_definitions (${PROJECT_NAME} PRIVATE WIN_EXPORT)
54- target_compile_definitions (${PROJECT_NAME} PRIVATE SHARED_LIB)
51+ if (BUILD_SHARED_LIBS )
52+ if (WIN32 )
53+ target_compile_definitions (${PROJECT_NAME} PRIVATE WIN_EXPORT)
5554 endif ()
56- endif (MSVC )
55+ else ()
56+ target_compile_definitions (${PROJECT_NAME} PRIVATE MIRAICPP_STATICLIB)
57+ endif ()
58+
5759
5860
5961option (MIRAI_CPP_BUILD_EXAMPLES "Build examples" ON )
Original file line number Diff line number Diff line change 11#include < iostream>
2+ // 使用静态库必须要在引入 mirai.h 前定义这个宏
3+ #define MIRAICPP_STATICLIB
24#include < mirai.h>
35
46int main ()
Original file line number Diff line number Diff line change 44
55#include < exception>
66#include " serializable.hpp"
7+ #include " exported.h"
78
89namespace Cyan
910{
@@ -107,7 +108,7 @@ namespace Cyan
107108 };
108109
109110 // 预先声明 MiraiBot 类
110- class MiraiBot ;
111+ class EXPORTED MiraiBot;
111112
112113}
113114
Original file line number Diff line number Diff line change 11#pragma once
22
3- // Define EXPORTED for any platform
4- #if defined(_WIN32 )
5- # if defined(WIN_EXPORT ) && defined(SHARED_LIB )
3+ #if defined(MIRAICPP_STATICLIB )
4+ # define EXPORTED
5+ #elif defined(_WIN32 )
6+ # if defined(WIN_EXPORT )
67# define EXPORTED __declspec( dllexport )
78# else
89# define EXPORTED __declspec( dllimport )
You can’t perform that action at this time.
0 commit comments