Home >Backend Development >PHP7 >Explain how to compile php7 graphics library php_ui.dll under windows

Explain how to compile php7 graphics library php_ui.dll under windows

coldplay.xixi
coldplay.xixiforward
2021-02-26 09:28:182473browse

Explain how to compile php7 graphics library php_ui.dll under windows

Recommendation (free): PHP7

Having graphical programming is interesting, I have seen php ui these days Graphics extension, but now you can only download PHP 7.1. This tutorial compiles PHP UI of PHP7.2.6

It is relatively simple to compile under Linux, but it is more troublesome under Windows

Compile Environment setup

There are several important differences in the compilation of php7.2.6 (windows environment).

1.php7.2 is compiled with vc15 (vs2017)

2.php7’s sdk php-sdk

3. The compilation environment construction is simpler.

Specific environment construction

Install vc15 compiler

vs2017 separates the compiler and ide. Because we only need the compiler, we don’t need to install vs2017 (you can also install the free version of vs2017 directly)

Please download cmake separately under win and configure it into the system environment

http://landinghub.visualstudio.com/visual-cpp-build-tools

Click the download address Go to the download page and find "Visual Studio 2017 Generation Tool" below, download and install it

Be careful to select vc-related programs. Below is a screenshot of the installation


Download php-sdk and unzip

https://github.com/Microsoft/php-sdk-binary-tools

Extract to d:\php_sdk\ (assuming we are going to use d:\php_sdk\ as the compilation directory)

At this time there should be

## under d:\php_sdk\


#Run phpsdk-vc15-x86.bat in J:\compiler\php\sdk\binary-tools

Click in the php_sdk directory Hold the shift key and right-click "Open command line window here"

Run "phpsdk-vc15-x86.bat" in the command line window

Note: If you want to compile the 64-bit version, run it x64,

The result is as shown below (the phpsdk directory is different)



Run phpsdk_buildtree phpdev

At this time J:\compiler \php\sdk\There should be a phpdev directory below

Download libui

Extract to any Directory

mkdir build && cd build 
cmake -G"NMake Makefiles" NDEBUG ..
打开
CMakeFiles\libui.dir\build.make:1298
	resources.rc.* 改成 resources.rc.res
cmake --build .
libui-alpha3.5\build\out
out\libui.lib 和 out\libui.res 复制到 J:\compiler\php\sdk\phpdev\vc15\x64\phpdev\vc15\x64\deps\lib
libui-alpha3.5
ui.h 复制到 J:\compiler\php\sdk\phpdev\vc15\x64\phpdev\vc15\x64\deps\include
ui_darwin.h 复制到 J:\compiler\php\sdk\phpdev\vc15\x64\phpdev\vc15\x64\deps\include
ui_unix.h 复制到 J:\compiler\php\sdk\phpdev\vc15\x64\phpdev\vc15\x64\deps\include
ui_windows.h 复制到 J:\compiler\php\sdk\phpdev\vc15\x64\phpdev\vc15\x64\deps\include

Download pthreads-w32-2-9-1-release Click to download page

pthreadVC2.lib 复制到 J:\compiler\php\sdk\phpdev\phpdev\vc15\x64\deps\lib

Open pthread.h and add preprocessing content at the beginning as follows

#define HAVE_STRUCT_TIMESPEC
#define _TIMESPEC_DEFINED

Copy this file to

J:\compiler\php\sdk\phpdev\phpdev\vc15\x64\deps\include

Download php ui

https:// github.com/krakjoe/ui
If you have a current version, you can download it directly
http://pecl.php.net/package/ui
Manual
http://php.net/ui

Extract to the php ext directory and rename it to ui

Enter the php-src directory and execute the

command line "cd /d J:\compiler\php\sdk\phpdev\vc15\x64\php-7.2.6 " Enter the php source code directory

Command line "phpsdk_deps --update --branch master" PHP will automatically download the required dependency packages (previously required Manually download the php-dsp file)

See the words successfully indicating that the download is complete

Execute "buildconf"

Command line execution "buildconf"

If you are prompted that there is no script engine with file extension ".js"

You can download the file and run it Solve click to jump

重新执行 buildconf

结果如下 说明运行完毕

  1. $ buildconf  
  2. Rebuilding configure.js  
  3. Now run 'configure --help' 

编译php

configure --disable-all --enable-cli --enable-fd-setsize=2048 --enable-sanitizer --with-ui=shared --with-curl=shared --disable-cgi
扩展
--disable-zts
--disable-cgi   编译出 windows 版本和 php-cgi.exe  
--disable-zts   nts 非线程安全  
--enable-shmop=shared   以dll 方式编译 php shmop 扩展
Makefile 如果链接提示库不存在 可修改makefile 修改如下
	LIBS=kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib psapi.lib bcrypt.lib comdlg32.lib  Gdi32.lib comctl32.lib version.lib d2d1.lib dwrite.lib windowscodecs.lib dxgi.lib d3d12.lib ScrnSave.Lib USP10.Lib UxTheme.lib

然后执行"nmake" 开始编译

等待数分钟(或者数10分钟)后,在php-源码目录应该能够找到 Release_TS 目录看见 php-ui了

最后 pthreadVC2.dll 和 libui.dll 复制到php 根目录 

php-ui.dll 复制到 php ext目录

php ini 新增 

extension=ui

ok下面是运行截图


下面是编译好了的

点击到下载页面

The above is the detailed content of Explain how to compile php7 graphics library php_ui.dll under windows. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete