Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling geos without root CentOS

I have been trying to compile geos on my restrcited(no root) environment and I am having some difficulties...

I did the following

wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
tar jxf geos-3.4.2.tar.bz2
cd geos-3.4.2
nano ~/.bash_profile
# I added PATH=$PATH:$HOME/local/bin export PATH
./configure --enable-php --prefix=$HOME/local/ && make clean && make

And Im getting the following errors

Making all in php
make[2]: Entering directory `/home/myname/test/geos-3.4.2/php'
Making all in .
make[3]: Entering directory `/home/myname/test/geos-3.4.2/php'
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include -I../include/geos   `/usr/local/bin/php-config --includes` -DCOMPILE_DL_GEOS -I../capi -I../include -I./opt/alt/php53/usr/include/ -pedantic -Wall -ansi -Wno-long-long  -ffloat-store -std=gnu99 -g -O2 -MT geos_la-geos.lo -MD -MP -MF .deps/geos_la-geos.Tpo -c -o geos_la-geos.lo `test -f 'geos.c' || echo './'`geos.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -I../include/geos -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DCOMPILE_DL_GEOS -I../capi -I../include -I./opt/alt/php53/usr/include/ -pedantic -Wall -ansi -Wno-long-long -ffloat-store -std=gnu99 -g -O2 -MT geos_la-geos.lo -MD -MP -MF .deps/geos_la-geos.Tpo -c geos.c  -fPIC -DPIC -o .libs/geos_la-geos.o
geos.c:26:17: error: php.h: No such file or directory
geos.c:27:54: error: ext/standard/info.h: No such file or directory
geos.c:28:72: error: Zend/zend_exceptions.h: No such file or directory

According to some github, this happens with MAMP too

This happens because GEOS requires PHP header files from the original PHP source, and MAMP does not include those.

EDIT 1:

I have also added this in ~/local/share/config.site

CPPFLAGS=-I./opt/alt/php53/usr/include/
LDFLAGS=-L$HOME/local/lib

php.h is located here: ./opt/alt/php53/usr/include/php/main/php.h

info.h: ./opt/alt/php53/usr/include/php/ext/standard/info.h

zend_exceptions.h: ./opt/alt/php53/usr/include/php/Zend/zend_exceptions.h

EDIT 2:

Last thing: my ./configure tells me this

checking for php-config... /usr/local/bin/php-config
checking for php... /usr/local/bin/php

So my question, if Im on the right track for solving this, is how do I include my php header files while compiling geos in a non root evnironment in centOs ?

Im quite lost to be honest !

like image 755
delmalki Avatar asked Nov 09 '22 09:11

delmalki


1 Answers

I'm fairly certain the path to your PHP installation does not start with a . - not from inside the geos-3.4.2 folder anyway, and certainly not from inside an arbitrary source folder.
You should make that path absolute.

I'm assuming the opt folder is in your user folder, so the full path would be $HOME/opt/alt/php53/usr/. Thanks for the clarification, the full path should then be /opt/alt/php53/usr/.
You need to add the bin folder to your PATH variable, the include folder to CPPFLAGS and the lib folder to LDFLAGS.
With $HOME/local/ this is not necessary, since that is the PREFIX, and will be added automatically.
Also note that when adding stuff to your PATH variable, you should add it to the beginning instead of the end, so that it will take precedence over system binaries.

I also suggest you undo the changes you made to ~/local/share/config.site (or remove the file, if it didn't exist), as options there will affect all automake-based projects.
You should rather pass CPPFLAGS and LDFLAGS as arguments to configure.

After all that, your command block should look something like:

wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
tar jxf geos-3.4.2.tar.bz2
cd geos-3.4.2
export PATH="/opt/alt/php53/usr/bin:$PATH"
./configure --enable-php --prefix="$HOME/local" CPPFLAGS="-I/opt/alt/php53/usr/include" LDFLAGS="/opt/alt/php53/usr/lib" && make clean && make
like image 163
Siguza Avatar answered Nov 15 '22 05:11

Siguza