SWIGCMakePHPExampleWindows/README.md

32 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2018-06-30 23:41:28 +02:00
# SWIG CMake PHP Example for Windows
2018-06-30 23:59:58 +02:00
Example on how to build a SWIG/PHP Extension with CMake on Windows.
2018-06-30 23:37:25 +02:00
2018-06-30 23:45:30 +02:00
Couldn't find any working example even without CMake for Windows so i created this one ;)
Hope it helps others.
You need Visual Studio installed.
For current Version of PHP, you need current Version of VS2017 (Community Edition is okay)
2018-06-30 23:37:25 +02:00
To build this Example, build PHP as descriped here: https://github.com/Microsoft/php-sdk-binary-tools
2018-06-30 23:39:31 +02:00
2018-06-30 23:37:25 +02:00
You need SWIG to make this work.
2018-06-30 23:39:31 +02:00
2018-06-30 23:37:25 +02:00
Current SWIG (3.0.12) has a Problem with building Extensions on Windows with Thread-Safe PHP.
2018-06-30 23:39:31 +02:00
2018-06-30 23:37:25 +02:00
So until SWIG 4.0.0 is released, you need to build SWIG, too.
2018-06-30 23:39:31 +02:00
2018-06-30 23:37:25 +02:00
I have a fork of swig in my github account which enables you to build it with cmake: https://github.com/AlexanderGabriel/swig
2018-06-30 23:39:31 +02:00
2018-06-30 23:37:25 +02:00
Build it and change the path SWIG_EXECUTABLE and SWIG_DIR to your environment.
2018-06-30 23:45:30 +02:00
You can stay inside PHP-SDK-Shell if you want or open a new x64/x86 Native Tools Command Prompt for VS 2017.
Change directory back to where you checked out this and then execute the following commands.
2018-06-30 23:37:25 +02:00
2018-06-30 23:45:30 +02:00
```
mkdir build
cd build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -Wno-dev -DSWIG_EXECUTABLE=C:\dev\work\swig\swig.exe -DSWIG_DIR=C:\dev\work\swig
cmake --build .
```
2018-06-30 23:37:25 +02:00
Thats it.
2018-10-06 21:08:51 +02:00
To see all commands, have a look into appveyor.yml