编译问题
编译|问题
这章节搜集了很多编译时会产生的错误情况。 1. 我用匿名CVS得到最新版的源代码包, 但没有配置脚本文件! 2. 我在配置 PHP 在 Apache下工作时出了问题。 它说不能找到 httpd.h, 可是我看它就在那里! 3. 当我运行conifgure时,它说它不能找到include文件或 一些库: GD, gdbm, 或其它的一些包! 4. 我在编译文件 language-parser.tab.c时, 出错,提示: yytname undeclared. 5. 当我运行 make, 起初正常但 最终失败了,在连接最后的应用时,出错说找不到一些文件。 6. 在连接 PHP 时, 出一堆错说 undefined references。 7. 我不清楚怎样在 Apache 1.3下编译PHP。 8. 我按照步骤一步一步安装了Apache模块(Unix下), 可是在浏览器里打开 PHP 脚本时它却问我是否要保存。 9. 系统说使用: --activate-module=src/modules/php4/libphp4.a, 可那文件根本不存在, 我只好改成 --activate-module=src/modules/php4/libmodphp4.a 好了,它不工作了! 该怎么办? 10. 我要把PHP编译成Apache的静态模块,用: --activate-module=src/modules/php4/libphp4.a 可是系统说我的编译器不是 ANSI 兼容的。 11. 我用 --with-apxs编译PHP时, 我总是得到一些奇怪的错误。 12. 在 make时, 我得到很多关于microtime错误, 还有许多 RUSAGE_ stuff. 13. 我想升级PHP,我在哪可以看到我现在运行的PHP 的当初配置安装时所使用的./configure 一行的内容? 14. 编译带GD库的PHP时,它不是给一些奇怪的错, 就是执行时产生 segfaults 段错误.
1. 我用匿名CVS得到最新版的源代码包, 但没有配置脚本文件!
你必须安装 GNU autoconf 包,这样可以从 configure.in生成配置脚本文件. 只要运行在CVS服务器得到源代码的顶级目录下的 ./buildconf。 (注意, 除非你运行configure --enable-maintainer-mode 选项, 配置脚本是不会重新生成, 即使configure.in 文件已更新, 所以当你发现 configure.in 改变了,你也要手工做一遍. 在config或config.status 运行后应该在你的Makefile里能看到象@VARIABLE@这样的标号。)
2. 我在配置 PHP 在 Apache下工作时出了问题。 它说不能找到 httpd.h, 可是我看它就在那里!
你要告诉 configure/setup 脚本 Apache 的顶级目录的位置。 就是说你要标明 --with-apache=/path/to/apache , 而不是 --with-apache=/path/to/apache/src.
3. 当我运行conifgure时,它说它不能找到include文件或 一些库: GD, gdbm, 或其它的一些包!
你可以看看 configure 脚本,那些头文件或非标准库的位置,要送一些特殊的标志给C预处理器。例如:
CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
env CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
4. 我在编译文件 language-parser.tab.c时, 出错,提示: yytname undeclared.
你需要更新你的 Bison 版本. 你可以在 ftp://ftp.gnu.org/pub/gnu/bison/找到最新版本.
5. 当我运行 make, 起初正常但 最终失败了,在连接最后的应用时,出错说找不到一些文件。
一些老版本的 make 不能把 functions 目录下的编译的文件放到同一个目录下, 试着运行 cp *.o functions 然后再运行 make 看看是否会好些。 如果好了,你真的应该更新你的GNU Make的版本了。
6. 在连接 PHP 时, 出一堆错说 undefined references。
看看文件里的连接行,确认所有的相关包都已经正确包含。通常这样是因为缺少'-ldl',还有一些你想支持的数据库包。
如果你是在连接到 Apache 1.2.x, 你记得要在在EXTRA_LIBS 行增加一些额外的信息 并且重运行 Apache's Configure 脚本吗? 参见发行包里的 INSTALL 文件。
很多人说他们一增加 '-ldl' 马上得到了 libphp4.a 。
7. 我不清楚怎样在 Apache 1.3下编译PHP。
事实上很简单,按下面的步骤:
-
取得 Apache 1.3 源代码,在下面的位置 http://www.apache.org/dist/. -
在某个目录下解压出来, 如 /usr/local/src/apache-1.3. -
在PHP的发行包目录下,编译 PHP ,./configure --with-apache=//apache-1.3 ( 用户实际的apache-1.3目录位置替代.
打入: make 然后: make install 编译PHP,拷必须的文件到Apache目录下。
改变到你的 //apache-1.3/src 目录,编辑 Configuration文件. 把下面的行增加到文件里: AddModule modules/php4/libphp4.a.
打入: ./Configure 然后: make.
这样你就有了一个 httpd 文件!
注意:你也可以使用新的Apache ./configure 脚本. 见发行包里的 README.configure 当然也要看看PHP发行包里的 INSTALL 文件。
8. 我按照步骤一步一步安装了Apache模块(Unix下), 可是在浏览器里打开 PHP 脚本时它却问我是否要保存。
这意味着你的PHP模块没有被加载。你可从下面三点来检查:
-
确认你运行的Httpd是你刚刚编译了PHP的Httpd. 可以运行: /path/to/binary/httpd -l
如果你没有看到 mod_php4.c 列出来,那么你运行了不正确的Httpd. 最好重新安装它。 -
确认你在 Apache .conf 文件里增加了正确的Mime 类型.它应该是这样: AddType application/x-httpd-php3 .php3 ( PHP 3)
或 AddType application/x-httpd-php .php ( PHP 4)
也保证 AddType 这行没有包括在或 块里,它们会使它无效。
最后, Apache 1.2 和 Apache 1.3默认的配置文件的位置是不同的. 你应该检查你增加了AddType行的配置文件的位置 . 你可以在 httpd.conf 放一些明显的错误或改变,这样如果这文件被读的话,系统会通知你。
9. 系统说使用: --activate-module=src/modules/php4/libphp4.a, 可那文件根本不存在, 我只好改成 --activate-module=src/modules/php4/libmodphp4.a 好了,它不工作了! 该怎么办?
请注意 libphp4.a 事实并不存在. apache 进程会创建它!
10. 我要把PHP编译成Apache的静态模块,用: --activate-module=src/modules/php4/libphp4.a 可是系统说我的编译器不是 ANSI 兼容的。
这个错误消息是 Apache 误导的,可以用更新版本来修正它。
11. 我用 --with-apxs编译PHP时, 我总是得到一些奇怪的错误。
出现这样的情况可以从三点来检查. 第一, 因为某种原因,Apache 在编译apxs Perl 脚本的时候, 它没有创建适当的标志变量, 找到你的apxs脚本 (试试命令 which apxs, 通常在 /usr/local/apache/bin/apxs or /usr/sbin/apxs. 打开它找到象下面这样的行:
my $CFG_CFLAGS_SHLIB = ' '; # substituted via Makefile.tmplmy $CFG_LD_SHLIB = ' '; # substituted via Makefile.tmplmy $CFG_LDFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl
my $CFG_CFLAGS_SHLIB = '-fpic -DSHARED_MODULE'; # substituted via Makefile.tmplmy $CFG_LD_SHLIB = 'gcc'; # substituted via Makefile.tmplmy $CFG_LDFLAGS_SHLIB = q(-shared); # substituted via Makefile.tmpl
my $CFG_LIBEXECDIR = 'modules'; # substituted via APACI install
my $CFG_LIBEXECDIR = '/usr/lib/apache'; # substituted via APACI install
12. 在 make时, 我得到很多关于microtime错误, 还有许多 RUSAGE_ stuff.
在安装过程中 make时,如果你看到下面的错:
microtime.c: In function `php_if_getrusage':microtime.c:94: storage size of `usg' isn't knownmicrotime.c:97: `RUSAGE_SELF' undeclared (first use in this function)microtime.c:97: (Each undeclared identifier is reported only oncemicrotime.c:97: for each function it appears in.)microtime.c:103: `RUSAGE_CHILDREN' undeclared (first use in this function)make[3]: *** [microtime.lo] Error 1make[3]: Leaving directory `/home/master/php-4.0.1/ext/standard'make[2]: *** [all-recursive] Error 1make[2]: Leaving directory `/home/master/php-4.0.1/ext/standard'make[1]: *** [all-recursive] Error 1make[1]: Leaving directory `/home/master/php-4.0.1/ext'make: *** [all-recursive] Error 1
那是你的系统出错了. 你应该修复 /usr/include 文件.具体做法是安装和你的glibc匹配的glibc-devel 包. 这些错绝对和PHP无关,为了证明,你可以这样做:
$ cat >test.c X$ gcc -E test.c >/dev/null
13. 我想升级PHP,我在哪可以看到我现在运行的PHP 的当初配置安装时所使用的./configure 一行的内容.?
你可以看你安装PHP源目录下的 config.nice 文件. 如果不行还有另外一种方法.你只要简单运行
<?php phpinfo(); ?>
14. 编译带GD库的PHP时,它不是给一些奇怪的错, 就是执行时产生 segfaults 段错误.
你必须确认你在编译 GD 库 和 PHP 时所使用同样的依赖库 (例如 libpng).

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP provides tools to allow websites to easily integrate social media functions: 1. Dynamically generate social media sharing buttons for users to share content; 2. Integrate with the OAuth library to achieve seamless social media login; 3. Use the HTTP library to capture social media Data, obtain user profile, posts and other information.
