mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 00:26:28 -04:00
Tidy up plugin compiling instructions, especially for mingw-w64
This commit is contained in:
parent
8077a9f5cf
commit
9eb115c991
@ -133,7 +133,7 @@ if __name__ == "__main__":
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### static/classisphere.js
|
#### static/classisphere.js
|
||||||
Download `cs.classicube.net/c_client/latest/ClassiCube.js` for this
|
Download `cs.classicube.net/client/latest/ClassiCube.js` for this
|
||||||
|
|
||||||
#### static/default.zip
|
#### static/default.zip
|
||||||
Download `classicube.net/static/default.zip` for this
|
Download `classicube.net/static/default.zip` for this
|
||||||
|
@ -11,7 +11,7 @@ For example, let's assume our site is setup like this:
|
|||||||
* `example.com/static/default.zip`
|
* `example.com/static/default.zip`
|
||||||
|
|
||||||
For simplicitly,
|
For simplicitly,
|
||||||
1) Download `cs.classicube.net/c_client/latest/ClassiCube.js`, then upload it to `static/classisphere.js` on the webserver
|
1) Download `cs.classicube.net/client/latest/ClassiCube.js`, then upload it to `static/classisphere.js` on the webserver
|
||||||
2) Download `classicube.net/static/default.zip`, then upload it to `static/default.zip` on the webserver
|
2) Download `classicube.net/static/default.zip`, then upload it to `static/default.zip` on the webserver
|
||||||
|
|
||||||
The play.html page is the trickiest part, because how to implement this is website-specific. (depends on how your website is styled, what webserver you use, what programming language is used to generate the html, etc)
|
The play.html page is the trickiest part, because how to implement this is website-specific. (depends on how your website is styled, what webserver you use, what programming language is used to generate the html, etc)
|
||||||
|
@ -16,7 +16,7 @@ I assume your directory is structured like this:
|
|||||||
src/...
|
src/...
|
||||||
TestPlugin.c
|
TestPlugin.c
|
||||||
```
|
```
|
||||||
Or in other words, in a directory somewhere, you have a file named ```TestPlugin.c```, and then a sub-directory named ```src``` which contains the game's source code.
|
Or in other words, in a directory somewhere, you have a file named `TestPlugin.c`, and then a sub-directory named `src` which contains the game's source code.
|
||||||
|
|
||||||
### Basic plugin
|
### Basic plugin
|
||||||
```C
|
```C
|
||||||
@ -51,8 +51,8 @@ Here's the idea for a basic plugin that shows "Hello world" in chat when the gam
|
|||||||
#include "src/String.h"
|
#include "src/String.h"
|
||||||
|
|
||||||
static void TestPlugin_Init(void) {
|
static void TestPlugin_Init(void) {
|
||||||
cc_string msg = String_FromConst("Hello world!");
|
cc_string msg = String_FromConst("Hello world!");
|
||||||
Chat_Add(&msg);
|
Chat_Add(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT int Plugin_ApiVersion = 1;
|
EXPORT int Plugin_ApiVersion = 1;
|
||||||
@ -112,50 +112,64 @@ Plugin compilation instructions differs depending on the compiler and operating
|
|||||||
## Compiling - Linux
|
## Compiling - Linux
|
||||||
|
|
||||||
### Using gcc or clang
|
### Using gcc or clang
|
||||||
|
|
||||||
#### Compiling
|
#### Compiling
|
||||||
|
|
||||||
```cc TestPlugin.c -o TestPlugin.so -shared -fPIC```
|
`cc TestPlugin.c -o TestPlugin.so -shared -fPIC`
|
||||||
|
|
||||||
Then put ```TestPlugin.so``` into your game's ```plugins``` folder. Done.
|
Then put `TestPlugin.so` into your game's `plugins` folder. Done.
|
||||||
|
|
||||||
### Cross compiling for Windows 32 bit using mingw-w64
|
### Cross compiling for Windows 32 bit using mingw-w64
|
||||||
|
|
||||||
#### Setup
|
#### Setup
|
||||||
|
|
||||||
1) Compile the game, see ```Cross compiling for windows``` in main readme
|
1) Create `ClassiCube.exe` by either:
|
||||||
2) Rename compiled executable to ClassiCube.exe
|
1) Compiling the game, see `Cross compiling for windows (32 bit)` in [main readme](/readme.md#cross-compiling-for-windows-32-bit)
|
||||||
3) Install the ```mingw-w64-tools``` package
|
2) Downloading 32 bit ClassiCube from https://www.classicube.net/download/#dl-win
|
||||||
|
2) Install the `mingw-w64-tools` package (if it isn't already)
|
||||||
TODO: this also works for mingw. clean this up.
|
3) Generate the list of exported symbols from `ClassiCube.exe` by running:
|
||||||
|
* `gendef ClassiCube.exe`
|
||||||
|
4) Create a linkable library from the exported symbols list by running:
|
||||||
|
* `i686-w64-mingw32-dlltool -d ClassiCube.def -l libClassiCube.a -D ClassiCube.exe`
|
||||||
|
|
||||||
TODO: also document alternate method of compiling the game using --out-implib
|
TODO: also document alternate method of compiling the game using --out-implib
|
||||||
|
|
||||||
#### Compiling
|
#### Compiling
|
||||||
|
|
||||||
First, generate list of exported symbols:
|
`i686-w64-mingw32-gcc TestPlugin.c -o TestPlugin.dll -s -shared -L . -lClassiCube`
|
||||||
|
|
||||||
```gendef src/ClassiCube.exe```
|
Then put `TestPlugin.dll` into your game's `plugins` folder. Done.
|
||||||
|
|
||||||
Next create a linkable library:
|
|
||||||
|
|
||||||
```i686-w64-mingw32-dlltool -d ClassiCube.def -l libClassiCube.a -D ClassiCube.exe```
|
|
||||||
|
|
||||||
Finally compile the plugin:
|
|
||||||
|
|
||||||
```i686-w64-mingw32-gcc TestPlugin.c -o TestPlugin.dll -s -shared -L . -lClassiCube```
|
|
||||||
|
|
||||||
Then put ```TestPlugin.dll``` into your game's ```plugins``` folder. Done.
|
|
||||||
|
|
||||||
### Cross compiling for Windows 64 bit using mingw-w64
|
### Cross compiling for Windows 64 bit using mingw-w64
|
||||||
Repeat the steps of *Cross compiling for Windows 32 bit*, but replace ```i686-w64-mingw32``` with ```x86_64-w64-mingw32```
|
|
||||||
|
#### Setup
|
||||||
|
|
||||||
|
1) Create `ClassiCube.exe` by either:
|
||||||
|
1) Compiling the game, see `Cross compiling for windows (64 bit)` in [main readme](/readme.md#cross-compiling-for-windows-64-bit)
|
||||||
|
2) Downloading 64 bit ClassiCube from https://www.classicube.net/download/#dl-win
|
||||||
|
2) Install the `mingw-w64-tools` package (if it isn't already)
|
||||||
|
3) Generate the list of exported symbols from `ClassiCube.exe` by running:
|
||||||
|
* `gendef ClassiCube.exe`
|
||||||
|
4) Create a linkable library from the exported symbols list by running:
|
||||||
|
* `x86_64-w64-mingw32-dlltool -d ClassiCube.def -l libClassiCube.a -D ClassiCube.exe`
|
||||||
|
|
||||||
|
TODO: also document alternate method of compiling the game using --out-implib
|
||||||
|
|
||||||
|
#### Compiling
|
||||||
|
|
||||||
|
`x86_64-w64-mingw32-gcc TestPlugin.c -o TestPlugin.dll -s -shared -L . -lClassiCube`
|
||||||
|
|
||||||
|
Then put `TestPlugin.dll` into your game's `plugins` folder. Done.
|
||||||
|
|
||||||
## Compiling - macOS
|
## Compiling - macOS
|
||||||
|
|
||||||
### Using gcc or clang
|
### Using gcc or clang
|
||||||
|
|
||||||
#### Compiling
|
#### Compiling
|
||||||
|
|
||||||
```cc TestPlugin.c -o TestPlugin.dylib -undefined dynamic_lookup```
|
`cc TestPlugin.c -o TestPlugin.dylib -undefined dynamic_lookup`
|
||||||
|
|
||||||
Then put ```TestPlugin.dylib``` into your game's ```plugins``` folder. Done.
|
Then put `TestPlugin.dylib` into your game's `plugins` folder. Done.
|
||||||
|
|
||||||
## Compiling - Windows
|
## Compiling - Windows
|
||||||
|
|
||||||
@ -164,7 +178,7 @@ TODO more detailed when I have some more time...
|
|||||||
|
|
||||||
#### Setup
|
#### Setup
|
||||||
|
|
||||||
1) Compile the game, see ```Cross compiling for windows``` in main readme
|
1) Compile the game, see `Cross compiling for windows` in main readme
|
||||||
2) Find the `ClassiCube.lib` that was generated when compiling the game. Usually it is in either `src\x64\Debug` or `src\x86\Debug`.
|
2) Find the `ClassiCube.lib` that was generated when compiling the game. Usually it is in either `src\x64\Debug` or `src\x86\Debug`.
|
||||||
3) Add a new `Empty Project` to the ClassiCube solution, then add the plugin .c files to it
|
3) Add a new `Empty Project` to the ClassiCube solution, then add the plugin .c files to it
|
||||||
|
|
||||||
@ -174,17 +188,17 @@ Note: If the plugin provides a .vcxproj file, you can skip step 2 and just open
|
|||||||
|
|
||||||
The simplest way of linking to the `.lib` file is simply adding the following code to one of the plugin's `.c` files
|
The simplest way of linking to the `.lib` file is simply adding the following code to one of the plugin's `.c` files
|
||||||
|
|
||||||
```C
|
`C
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#pragma comment(lib, "[GAME SOURCE]/x64/Debug/ClassiCube.lib")
|
#pragma comment(lib, "[GAME SRC FOLDER]/x64/Debug/ClassiCube.lib")
|
||||||
#else
|
#else
|
||||||
#pragma comment(lib, "[GAME SOURCE]/x86/Debug/ClassiCube.lib")
|
#pragma comment(lib, "[GAME SRC FOLDER]/x86/Debug/ClassiCube.lib")
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
```
|
`
|
||||||
|
|
||||||
replacing `[GAME SOURCE]` with the full path of `src` folder (e.g. `C:/Dev/ClassiCube/src`)
|
replacing `[GAME SRC FOLDER]` with the full path of `src` folder (e.g. `C:/Dev/ClassiCube/src`)
|
||||||
|
|
||||||
#### Configuration - alternative #2
|
#### Configuration - alternative #2
|
||||||
|
|
||||||
@ -203,33 +217,33 @@ TODO: may need to configure include directories
|
|||||||
#### Compiling
|
#### Compiling
|
||||||
|
|
||||||
Build the project. There should be a line in the build output that tells you where you can find the .dll file like this:
|
Build the project. There should be a line in the build output that tells you where you can find the .dll file like this:
|
||||||
```
|
`
|
||||||
Project1.vcxproj -> C:\classicube-dev\testplugin\src\x64\Debug\TestPlugin.dll
|
Project1.vcxproj -> C:\classicube-dev\testplugin\src\x64\Debug\TestPlugin.dll
|
||||||
```
|
`
|
||||||
|
|
||||||
Then put ```TestPlugin.dll``` into your game's ```plugins``` folder. Done.
|
Then put `TestPlugin.dll` into your game's `plugins` folder. Done.
|
||||||
|
|
||||||
### Using mingw-w64
|
### Using mingw-w64
|
||||||
|
|
||||||
#### Setup
|
#### Setup
|
||||||
|
|
||||||
Generate the list of exported symbols of `ClassiCube.exe`
|
1) Create `ClassiCube.exe` by either:
|
||||||
|
1) Compiling the game, see `Compiling for windows (MinGW-w64)` in [main readme](/readme.md#using-mingw-w64)
|
||||||
```gendef src/ClassiCube.exe```
|
2) Downloading ClassiCube from https://www.classicube.net/download/#dl-win
|
||||||
|
2) Generate the list of exported symbols in `ClassiCube.exe` by running:
|
||||||
Next create a linkable library from the exported symbols list:
|
* `gendef ClassiCube.exe`
|
||||||
|
3) Create a linkable library from the exported symbols list by running:
|
||||||
```dlltool -d ClassiCube.def -l libClassiCube.a -D ClassiCube.exe```
|
* `dlltool -d ClassiCube.def -l libClassiCube.a -D ClassiCube.exe`
|
||||||
|
|
||||||
#### Compiling
|
#### Compiling
|
||||||
|
|
||||||
```gcc TestPlugin.c -o TestPlugin.dll -s -shared -L . -lClassiCube```
|
`gcc TestPlugin.c -o TestPlugin.dll -s -shared -L . -lClassiCube`
|
||||||
|
|
||||||
Then put ```TestPlugin.dll``` into your game's ```plugins``` folder. Done.
|
Then put `TestPlugin.dll` into your game's `plugins` folder. Done.
|
||||||
|
|
||||||
## Compiling - other notes
|
## Compiling - other notes
|
||||||
|
|
||||||
##### Ultra small dlls - mingw
|
##### Ultra small dlls - mingw
|
||||||
If you **ONLY** use code from the game (no external libraries and no C standard library functions), add ```-nostartfiles -Wl,--entry=0``` to the compile flags
|
If you **ONLY** use code from the game (no external libraries and no C standard library functions), add `-nostartfiles -Wl,--entry=0` to the compile flags
|
||||||
|
|
||||||
This step isn't necessary, the dll works fine without it. But it does reduce the size of the dll from 11 to 4 kb.
|
This step isn't necessary, the dll works fine without it. But it does reduce the size of the dll from 11 to 4 kb.
|
||||||
|
@ -59,14 +59,14 @@ I am assuming you used the installer from https://sourceforge.net/projects/mingw
|
|||||||
1. Install MinGW-W64
|
1. Install MinGW-W64
|
||||||
2. Use either *Run Terminal* from Start Menu or run *mingw-w64.bat* in the installation folder
|
2. Use either *Run Terminal* from Start Menu or run *mingw-w64.bat* in the installation folder
|
||||||
3. Navigate to directory with game's source code
|
3. Navigate to directory with game's source code
|
||||||
4. Enter `gcc *.c -o ClassiCube.exe -mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32`
|
4. Enter `gcc *.c -o ClassiCube.exe -mwindows -lwinmm -limagehlp`
|
||||||
|
|
||||||
##### Using MinGW
|
##### Using MinGW
|
||||||
I am assuming you used the installer from http://www.mingw.org/
|
I am assuming you used the installer from http://www.mingw.org/
|
||||||
1. Install MinGW. You need mingw32-base-bin and msys-base-bin packages.
|
1. Install MinGW. You need mingw32-base-bin and msys-base-bin packages.
|
||||||
2. Run *msys.bat* in the *C:\MinGW\msys\1.0* folder.
|
2. Run *msys.bat* in the *C:\MinGW\msys\1.0* folder.
|
||||||
3. Navigate to directory with game's source code
|
3. Navigate to directory with game's source code
|
||||||
4. Enter `gcc *.c -o ClassiCube.exe -mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32`
|
4. Enter `gcc *.c -o ClassiCube.exe -mwindows -lwinmm -limagehlp`
|
||||||
|
|
||||||
##### Using TCC
|
##### Using TCC
|
||||||
I am assuming you used `tcc-0.9.27-win64-bin.zip` from https://bellard.org/tcc/
|
I am assuming you used `tcc-0.9.27-win64-bin.zip` from https://bellard.org/tcc/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user