I'm trying to develop a PHP extension with PHP-CPP in Windows. I was able to compile the .a and .so of PHP-CPP with MingW, but when I compile the extension it does not find phpcpp.h.
Home
My Makefile File:
NAME = Teste
INI_DIR = /etc/php5/conf.d
EXTENSION_DIR = $(shell php-config --extension-dir)
EXTENSION = ${NAME}.so
INI = ${NAME}.ini
COMPILER = g++
LINKER = g++
PHP_CONFIG = php-config
COMPILER_FLAGS = -Wall -c -O2 -std=c++11 -fpic -o
LINKER_FLAGS = -shared
LINKER_DEPENDENCIES = -lphpcpp
RM = rm -f
CP = cp -f
MKDIR = mkdir -p
SOURCES = $(wildcard *.cpp)
OBJECTS = $(SOURCES:%.cpp=%.o)
all: ${OBJECTS} ${EXTENSION}
${EXTENSION}: ${OBJECTS}
${LINKER} ${LINKER_FLAGS} -o $@ ${OBJECTS} ${LINKER_DEPENDENCIES}
${OBJECTS}:
${COMPILER} ${COMPILER_FLAGS} $@ ${@:%.o=%.cpp}
install:
${CP} ${EXTENSION} ${EXTENSION_DIR}
${CP} ${INI} ${INI_DIR}
clean:
${RM} ${EXTENSION} ${OBJECTS}
Folder Structure:
main.cpp
Makefile
phpcpp.a
phpcpp.so
I added the PHP-CPP files to the MingW Include folder and the error now is this:
C:\Users\PedroSoares\Desktop\PHP\build_folder>mingw32-make.exe all
g++ -Wall -c -O2 -std=c++11 -fpic -o main.o main.cpp
main.cpp:1:0: warning: -fpic ignored for target (all code is position independent) [enabled by default]
#include <phpcpp.h>
^
In file included from c:\mingw\include\phpcpp.h:34:0,
from main.cpp:1:
c:\mingw\include\phpcpp\inivalue.h:17:21: error: variable 'Php::PHPCPP_EXPORT Php::IniValue' has initializer but incomplete type
class PHPCPP_EXPORT IniValue
^
c:\mingw\include\phpcpp\inivalue.h:19:1: error: expected primary-expression before 'public'
public:
^
c:\mingw\include\phpcpp\inivalue.h:19:1: error: expected '}' before 'public'
c:\mingw\include\phpcpp\inivalue.h:19:1: error: expected ',' or ';' before 'public'
c:\mingw\include\phpcpp\inivalue.h:32:25: error: non-member function 'Php::operator int16_t()' cannot have cv-qualifier
operator int16_t () const
^
c:\mingw\include\phpcpp\inivalue.h:32:25: error: 'Php::operator int16_t()' must be a nonstatic member function
c:\mingw\include\phpcpp\inivalue.h:41:25: error: non-member function 'Php::operator int32_t()' cannot have cv-qualifier
operator int32_t () const
^
c:\mingw\include\phpcpp\inivalue.h:41:25: error: 'Php::operator int32_t()' must be a nonstatic member function
c:\mingw\include\phpcpp\inivalue.h:50:25: error: non-member function 'Php::operator int64_t()' cannot have cv-qualifier
operator int64_t () const
^
c:\mingw\include\phpcpp\inivalue.h:50:25: error: 'Php::operator int64_t()' must be a nonstatic member function
c:\mingw\include\phpcpp\inivalue.h:59:22: error: non-member function 'Php::operator bool()' cannot have cv-qualifier
operator bool () const
^
c:\mingw\include\phpcpp\inivalue.h:59:22: error: 'Php::operator bool()' must be a nonstatic member function
c:\mingw\include\phpcpp\inivalue.h:68:29: error: non-member function 'Php::operator std::string()' cannot have cv-qualifier
operator std::string () const
^
c:\mingw\include\phpcpp\inivalue.h:68:29: error: 'Php::operator std::string()' must be a nonstatic member function
c:\mingw\include\phpcpp\inivalue.h:77:30: error: non-member function 'Php::operator const char*()' cannot have cv-qualifier
operator const char * () const
^
c:\mingw\include\phpcpp\inivalue.h:77:30: error: 'Php::operator const char*()' must be a nonstatic member function
c:\mingw\include\phpcpp\inivalue.h:86:28: error: expected constructor, destructor, or type conversion before ';' token
operator double() const;
^
c:\mingw\include\phpcpp\inivalue.h:98:28: error: non-member function 'int64_t Php::numericValue()' cannot have cv-qualifier
int64_t numericValue() const;
^
c:\mingw\include\phpcpp\inivalue.h:104:22: error: non-member function 'bool Php::boolValue()' cannot have cv-qualifier
bool boolValue() const
^
c:\mingw\include\phpcpp\inivalue.h:113:31: error: non-member function 'std::string Php::stringValue()' cannot have cv-qualifier
std::string stringValue() const
^
c:\mingw\include\phpcpp\inivalue.h: In function 'std::string Php::stringValue()':
c:\mingw\include\phpcpp\inivalue.h:115:37: error: 'rawValue' was not declared in this scope
return std::string(rawValue());
^
c:\mingw\include\phpcpp\inivalue.h: At global scope:
c:\mingw\include\phpcpp\inivalue.h:122:28: error: non-member function 'const char* Php::rawValue()' cannot have cv-qualifier
const char *rawValue() const;
^
c:\mingw\include\phpcpp\inivalue.h:125:1: error: expected unqualified-id before 'private'
private:
^
c:\mingw\include\phpcpp\inivalue.h:147:1: error: 'PHPCPP_EXPORT' does not name a type
PHPCPP_EXPORT std::ostream &operator<<(std::ostream &stream, const IniValue &ini_val);
^
c:\mingw\include\phpcpp\inivalue.h:153:1: error: expected declaration before '}' token
}
^
Makefile:21: recipe for target 'main.o' failed
mingw32-make.exe: *** [main.o] Error 1