File tree Expand file tree Collapse file tree 10 files changed +115
-0
lines changed
Expand file tree Collapse file tree 10 files changed +115
-0
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,30 @@ project "app"
1717 targetname " app"
1818
1919 files { " src/main.cpp" }
20+
21+ defines { ' USING_DLL_A' , ' USING_DLL_B' }
22+ links ' dll'
23+
24+ project " dll"
25+ kind " SharedLib"
26+ targetname " dll"
27+
28+ files { " src/dll.cpp" , ' src/dll.h' }
29+
30+ defines { ' MAKING_DLL_A' , ' MAKING_DLL_B' }
31+ links ' lib'
32+
33+ project " lib"
34+ kind " StaticLib"
35+ targetname " lib"
36+
37+ files { " src/lib.cpp" , ' src/lib.h' }
38+ -- defines { 'MAKING_DLL_A'}
39+
40+ project " test"
41+ kind " ConsoleApp"
42+ targetname " test"
43+
44+ files { " src/test.cpp" }
45+ -- defines { 'USING_DLL_A' }
46+ links ' lib'
Original file line number Diff line number Diff line change 1+ #include " dll.h"
2+
13int main ()
24{
5+ A a;
6+ bar ();
7+ foo ();
38}
Original file line number Diff line number Diff line change 1+ ## wholearchive:
2+
3+ Export static library content from another shared library
Original file line number Diff line number Diff line change 1+ if (_ACTION == nil ) then
2+ return
3+ end
4+
5+ local LocationDir = " solution/%{_ACTION}"
6+
7+ workspace " Project"
8+ location (LocationDir )
9+ configurations {" Debug" , " Release" }
10+
11+ objdir (path .join (LocationDir , " obj" )) -- premake adds $(configName)/$(AppName)
12+ targetdir (path .join (LocationDir , " bin/%{cfg.buildcfg}" ))
13+
14+ startproject " app"
15+
16+ project " app"
17+ kind " ConsoleApp"
18+ targetname " app"
19+
20+ files { " src/main.cpp" }
21+
22+ defines { ' USING_DLL' }
23+ links ' dll'
24+
25+ project " dll"
26+ kind " SharedLib"
27+ targetname " dll"
28+
29+ files { " src/dll.cpp" , ' src/dll.h' }
30+
31+ defines { ' MAKING_DLL' }
32+ links ' lib'
33+
34+ project " lib"
35+ kind " StaticLib"
36+ targetname " lib"
37+
38+ files { " src/lib.cpp" , ' src/lib.h' }
39+
40+ project " test"
41+ kind " ConsoleApp"
42+ targetname " test"
43+
44+ files { " src/test.cpp" }
45+ links ' lib'
Original file line number Diff line number Diff line change 1+ #include " dll.h"
2+
3+ void foo () {}
Original file line number Diff line number Diff line change 1+ #include "lib.h"
2+
3+ #ifdef MAKING_DLL
4+ #define IMPORT_EXPORT __declspec(dllexport)
5+ #elif defined(USING_DLL )
6+ #define IMPORT_EXPORT __declspec(dllimport)
7+ #else // not making nor using DLL
8+ #define IMPORT_EXPORT
9+ #endif
10+
11+ IMPORT_EXPORT void foo ();
Original file line number Diff line number Diff line change 1+ #include " lib.h"
2+
3+ void bar ()
4+ {
5+ }
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ void bar ();
Original file line number Diff line number Diff line change 1+ #include " dll.h"
2+
3+ int main ()
4+ {
5+ bar ();
6+ foo ();
7+ }
Original file line number Diff line number Diff line change 1+ #include " lib.h"
2+
3+ int main ()
4+ {
5+ bar ();
6+ }
You can’t perform that action at this time.
0 commit comments