Calling C/C++ library function from PHP - How to send a -std=c+11 to compiler
I´ve found a solution. Here is the definitive code:
PHP_ARG_ENABLE(vehicles,
[Whether to enable the "vehicles" extension],
[ --enable-vehicles Enable "vehicles" extension support])
if test $PHP_VEHICLES != "no"; then
CXX_FLAGS="-std=c++0x"
PHP_REQUIRE_CXX()
PHP_SUBST(VEHICLES_SHARED_LIBADD)
PHP_ADD_LIBRARY(stdc++, 1, VEHICLES_SHARED_LIBADD)
PHP_NEW_EXTENSION(vehicles, vehicles.cc car.cc, $ext_shared)
fi
Make sure the CXX_FLAGS
goes before PHP_REQUIRE_CXX()
otherwise it won´t work.
There is also a macro called X_CXX_COMPILE_STDCXX_11([noext], [mandatory])
whose code is here that automates that process.
This solution not working for me. (With PHP7 extension) I found another solution
if test $PHP_VEHICLES != "no"; then
CXXFLAGS="-std=c++11"
PHP_REQUIRE_CXX()
PHP_SUBST(VEHICLES_SHARED_LIBADD)
PHP_ADD_LIBRARY(stdc++, 1, VEHICLES_SHARED_LIBADD)
PHP_NEW_EXTENSION(vehicles, vehicles.cc car.cc, $ext_shared)
fi
So basically The only change is CXX_FLAGS="-std=c++0x"
change to CXXFLAGS="-std=c++11"