菜单

How to compile PHP-Qt?

2011年07月24日 - php

error code:

cmake ..
-- Found Qt-Version 4.5.0
CMake Error at cmake/modules/FindPHP5.cmake:139 (LIST):
  list index: 0 out of range (-0, 18446744073709551615)
Call Stack (most recent call first):
  CMakeLists.txt:13 (include)

-- /main
CMake Error at CMakeLists.txt:16 (MESSAGE):
  PHP5 could not be found!

-- Configuring incomplete, errors occurred!


Add first line CMakeLists.txt
cmake_minimum_required(VERSION 2.8)

—————————————————————————-

It complains about not finding php5.

I tried to compile the php-qt source and got the same error.
cmake found my php version after making the following changes to the FindPHP5.cmake file.

Remove all the paths from the “PHP5_POSSIBLE_INCLUDE_PATHS” section and add the path where your php5 souce is located.

SET(PHP5_POSSIBLE_INCLUDE_PATHS
/usr/include/php5
/usr/local/include/php5
/usr/include/php
/usr/local/include/php
/usr/local/apache/php
)

to

SET(PHP5_POSSIBLE_INCLUDE_PATHS
/path/to/php5/source
}

Then I had a problem with php-config. After installing the php5-dev packages the php-config file could not be executed as user, and it throws an error when executing as root. However I found a php-config5 executable which does the job.

I had to change

FIND_PROGRAM(PHP5_CONFIG_EXECUTABLE
NAMES php5-config php-config
)

to

FIND_PROGRAM(PHP5_CONFIG_EXECUTABLE
NAMES php-config5 php5-config php-config
)

If the php-config executable you are using is called “php-config” or “php5-config” you should not have to change this.

Afterward cmake output gave me this:

— /usr/include/php5/main
— Found PHP5-Version 5.2.6-3ubuntu4.4

I you have the QT 4 dev packages installed it should compile (I didn’t install them so it didn’t build)

——————————————————————–

You can try to add a “PATH” part to the PHP5_CONFIG_EXECUTABLE section.
I don’t know of this works, but I give it a fair chance.

FIND_PROGRAM(PHP5_CONFIG_EXECUTABLE
NAMES php5-config php-config
)
to
FIND_PROGRAM(PHP5_CONFIG_EXECUTABLE
NAMES php5-config php-config
PATHS
/path/to/php-config
)

otherwise use “which” to make sure php-config in your path is pointing to the correct file or run “php-config5 –includes”. You should get output like:

-I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

发表评论

电子邮件地址不会被公开。 必填项已用*标注