Table of Contents
Preface
Native environment
Key issues
成果
Home PHP Framework Swoole Solution to the problem when compiling and installing Swoole on Mac that the .h file does not exist

Solution to the problem when compiling and installing Swoole on Mac that the .h file does not exist

Nov 05, 2020 pm 02:27 PM
mac swoole

Preface

1. Actually, I really didn’t expect that the installation process would be so Emmm... How to describe it, it’s that kind of thing. In fact, it’s not difficult if you say it’s difficult, but it’s It's also quite disgusting, and there are various problems caused by Mac's native environment and some files not loading automatically.

2. Also, there is really very little information on this kind of question, so record it.


Native environment


And Xcode is not installed.
The local version comes with PHP version 7.3
The local environment configuration tool uses MxSrvs, a Mac version of the PHP development environment. Tool official website: http://www.xsrvs.com/ Although the tool is small, it has all the essentials and is fully sufficient for development.

Key issues

1. The PHP header file cannot be found

2. The Openssl header file cannot be found (the error message is similar to that of PHP)

Preparation work

Official website requirements

Here is one more sentence. Although the official does not marked how many versions of AutoConf need more, it takes 2.68 or above when compiling and installation.

Download the source code package from GitDownload address, what I downloaded is

Installation process

Because it is local, I put the downloaded package directly into the console directory without writing the previous CD directory or the like, and then ran the following code, because I want to compile it into the PHP version in the tool, so The phpzie provided by the tool is used.

/Applications/MxSrvs/bin/php/bin/phpize./configure \--enable-openssl \--enable-http2  \make && sudo make install
Copy after login

Not surprisingly, I encountered problem 1. Neither Baidu nor Bing found anything related to this problem. Then I asked some group friends, and some people said it was because the version was too high. The most suitable version of Swoole is version 7.2.

In the end, the answer that pointed to the essence of the question gave me inspiration. The general answer means that starting from macOs 10.10 and later versions, the PHP version that comes with Mac has canceled some folders, that is to say, since The PHP that comes with it does not have the files required for compilation and installation.

Knowing the reason, it is actually easy to solve. After all, few of our developers use their own environment, so we only need to consider how to dynamically add the PHP version used by the tool to the system environment variable. . Since I have set the system environment variable path before, and I have a little impression, I figured out how to set the environment variable.
In fact, you set the environment variables through .bash_profile

However, after you restart, you need to enter

source ~/.bash_profile
Copy after login
Copy after login

on the command line every time to make it take effect, which is more convenient Trouble, we can use Mac's mechanism to automatically load .zshrc files and add

source ~/.bash_profile
Copy after login
Copy after login

to the end of the file so that manual input is not required every time. To achieve the purpose of dynamically setting environment variables.

At this point, the first problem is solved.

Continue the second installation, and then the second problem occurs. Solving this problem is relatively roundabout.
In fact, the problems encountered are essentially the same. They are all because the software that comes with Mac does not have this .h header file, so these problems occur. The first problem is to bind to the tool. Variables, it is a clever way to change environment variables. Logically speaking, this extension of openssl is used in many places, so it is installed in the overall environment of your own machine.
Before installing openssl, you need to install Xcode first. I did not skip this step. It seems that many environment variables on Mac are linked to the Xcode file directory. It is really disgusting, but it cannot be ignored. After installation, we Then install openssl, enter

brew install openssl
Copy after login


on the command line. If it is detected that yours already exists, you will be prompted to reinstall and run

brew reinstall openssl@1.1
Copy after login


其中有一句,就是让把这个添加到

If you need to have openssl@1.1 first in your PATH run:  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc
Copy after login

把这个也添加之前修改过的 .zshrc 文件即可。
接下来就是重头戏了。说白了就是简单的粘贴复制,把 openssl 的文件夹,路径为

/usr/local/Cellar/openssl@1.1/1.1.1h/include/openssl
Copy after login

复制到

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/
Copy after login

目录下即可
至此,第二个问题解决。

然后再运行编译 Swoole ,等待编译完成就可以了

成果


打完收工!

The above is the detailed content of Solution to the problem when compiling and installing Swoole on Mac that the .h file does not exist. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

3 tips to easily customize your Mac computer name, host name and Bonjour name 3 tips to easily customize your Mac computer name, host name and Bonjour name Mar 06, 2024 pm 12:20 PM

Many Mac users tend to keep the default name of their device and may never consider changing it. Many people choose to stick with the name from the initial setup, such as "Johnny's MacBook Air" or simply "iMac." Learning how to change the name of your Mac is a very useful skill, especially when you have multiple devices, as it can help you quickly distinguish and manage them. Next, we will teach you step by step how to change the computer name, host name and Bonjour name (local host name) in macOS system. Why should you change your Mac name? Changing the name of your Mac can not only show your personality, but also help improve the user experience: Personalize your Mac: The default name may not be to your taste, change it to a name you like.

pkg file to install on mac? pkg file to install on mac? Feb 20, 2024 pm 03:21 PM

Preface: Today, this site will share with you the relevant content about installing pkg files on Mac. If it can solve the problem you are facing now, don’t forget to follow this site and start now! The previous version of macos pkg cannot be installed to upgrade the operating system: If your laptop is using an older operating system version, it is recommended to upgrade to the latest operating system version. Because older versions may not support installation of the latest macOS system. Select "Erase" in Disk Utility, then select the Macos extension in the format, do not check the encryption option, and do not select the apfs format, and finally click the "Erase" button to solve the problem of being unable to complete the macOS installation. Drag the application's icon to the file starting with App

How to set up WeChat Mac to automatically convert voice messages into text - How to set up voice to text conversion How to set up WeChat Mac to automatically convert voice messages into text - How to set up voice to text conversion Mar 19, 2024 am 08:28 AM

Recently, some friends have consulted the editor about how to set up WeChat Mac to automatically convert voice messages into text. The following is a method for setting up WeChat Mac to automatically convert voice messages into text. Friends in need can come and learn more. Step 1: First, open the Mac version of WeChat. As shown in the picture: Step 2: Next, click "Settings". As shown in the picture: Step 3: Then, click "General". As shown in the picture: Step 4: Then check the option "Automatically convert voice messages in chat to text". As shown in the picture: Step 5: Finally, close the window. As shown in the picture:

3 Ways to Convert HEIC Photos to JPG on Mac 3 Ways to Convert HEIC Photos to JPG on Mac Mar 15, 2024 pm 08:43 PM

By default, iPhone takes photos from the camera in HEIC format. HEIC stands for High Efficiency Image Container and can hold more pixel data than PNG or JPG files, taking up significantly less space on iPhone storage compared to other formats. These files work best on iPhones but are not widely accepted on the internet because they often result in blurry/grainy pictures when you share them with non-Apple devices. To ensure that HEIC images are compatible on other devices, you may need to convert them to JPG format. This article will introduce how to convert HEIC images to JPG on Mac. How to Convert HEIC Photos to JPG on Mac [3 Methods] Method

Can't open compressed files on mac? Can't open compressed files on mac? Feb 20, 2024 pm 02:18 PM

Introduction: This article is here to introduce you to the related content about Mac compressed files that cannot be opened. I hope it will be helpful to you, let’s take a look. Why can't I open the decompressed rar file on Mac? Since you don't have Mac decompression software, I would like to recommend a Mac version of decompression software to everyone. It is similar to commonly used compression software on Windows such as 360 Compression. Simply open the file and unzip it easily. The operation steps for Apple Mac computers that cannot open RAR files are as follows: First, install the RAR file decompression application, and you need to enter your Apple ID account and password to complete the installation. In the second step, after the installation is complete, return to the Mac desktop and double-click the RAR file to open and decompress the file contents. 3. Turn on the power

How to post to Moments on WeChat Mac - How to post to Moments on WeChat Mac How to post to Moments on WeChat Mac - How to post to Moments on WeChat Mac Mar 18, 2024 pm 05:43 PM

Friends, do you know how to post Moments on WeChat Mac? Today I will explain how to post Moments on WeChat Mac. If you are interested, come and take a look with me. I hope it can help everyone. Step 1: After opening WeChat, click the Moments button on the left. Step 2: Next, click the camera button on the upper right side. Step 3: Enter the text content you want to send. Step 4: Next, click on who can watch. Step 5: In the pop-up box, select the viewable conditions and click OK. Step 6: Finally, click the Publish button.

Mac configuration file does not take effect? Mac configuration file does not take effect? Feb 20, 2024 pm 02:00 PM

Introduction: This article will introduce to you the relevant content about the mac configuration file not taking effect. I hope it will be helpful to you, let's take a look. The solution to the problem that environment variables cannot take effect under Mac. After configuring environment variables in the Mac system, it is found that they are only effective in the current terminal and will become invalid once the terminal is switched. After inquiry, it was found that the Mac system is pre-installed with a tool called ultimate shell-zsh, and the reading of environment variables needs to be set in the .zshrc file. 2. In order for our configuration file to take effect, we can only add the above configuration in .zshrc. If you don’t make the above settings, you will find that it will only take effect every time you source ~/.bash_profile. Re-open z next time.

New shortcut keys for mac (where can we set shortcut keys to help us operate mac more quickly) New shortcut keys for mac (where can we set shortcut keys to help us operate mac more quickly) Feb 20, 2024 pm 02:27 PM

Preface: This article is here to introduce you to the relevant content about new shortcut keys for Mac. I hope it will be helpful to you, let’s take a look. How to Set Copy and Paste Shortcuts on Mac To change the copy and paste shortcuts on your Mac, go to the upper left corner of the Apple menu and select System Preferences. In the System Preferences window, find and click the "Keyboard" option. This will open the keyboard settings, allowing you to customize shortcut keys, including copy and paste functions. On Mac computers, the default shortcut keys for copy and paste operations are "Command+C" for copying and "Command+V" for pasting. To do this, first open the text or image you want to copy and paste. After selecting the file, press the shortcut key "comma

See all articles