Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libgeos_c not found when in non-standard location #45

Open
edbennett opened this issue Jul 5, 2019 · 3 comments
Open

libgeos_c not found when in non-standard location #45

edbennett opened this issue Jul 5, 2019 · 3 comments

Comments

@edbennett
Copy link

When libgeos is installed in a location not in the default system search path (as it is on our HPC system, where it is loaded via a module), the configure script fails to add the correct linker flag to the Makeovers file.

Relevant section of configure output:

checking for geos-config... /apps/libraries/geos/3.7.0/el7/AVX512/intel-2018/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.7.0
checking GEOS version >= 3.3.0... yes
checking geos_c.h usability... yes
checking geos_c.h presence... yes
checking for geos_c.h... yes
checking geos: linking with -L/apps/libraries/geos/3.7.0/el7/AVX512/intel-2018/lib -lgeos_c... yes
checking for GEOS_init_r in -lgeos_c... yes
configure: Package CPP flags:  -I/apps/libraries/proj/4.9.3/el7/AVX512/intel-2018/include   -I/apps/libraries/geos/3.7.0/el7/AVX512/intel-2018/include -DPOSTGIS_GEOS_VERSION=35 -I./liblwgeom -DHAVE_LIBGEOM_INTERNAL_H
configure: Package LIBS:  -L/apps/libraries/proj/4.9.3/el7/AVX512/intel-2018/lib -lproj    -lgeos_c

But the final compilation step gives:

ld: cannot find -lgeos_c

Manually editing the second line of src/Makevars to include the -L/apps/libraries/geos/3.7.0/el7/AVX512/intel-2018/lib that configure already detected that it needs allows the library to link and install correctly.

I'm not good at autoconf, so I can't tell whether this is configure using some C++/linker flags that are not then used by R CMD INSTALL, or whether it's a logic bug in configure.ac where a variable is forgotten to be set.

@edbennett
Copy link
Author

It looks like #35 was in part trying to fix this issue, but given that configure.ac exists, manually editing configure seems like a suboptimal approach to fixing this issue.

@pat-s
Copy link
Member

pat-s commented Sep 4, 2019

Thanks. This approach works. Wondering if it could be solved upstream so that automatic detection works.

FYI, rather than editing src/Makevars you can put the GEOS linker into ~/.R/Makevars via

PKG_LIBS = -L/opt/spack/opt/spack/linux-centos7-x86_64/gcc-7.3.0/geos-3.6.2-2deshsxx4rhonyxbuhznmzyixdnfkqq4/lib -lgeos_c

@justbennet
Copy link
Contributor

I think this is a problem in the configure.ac script. I made this change to configure.ac

$ diff configure.ac ../lwgeom.new/configure.ac
427c427
<          AC_SUBST([PKG_LIBS], ["${PKG_LIBS} -lgeos_c"]), 
---
>          AC_SUBST([PKG_LIBS], ["${PKG_LIBS} ${GEOS_LIBS}"]), 

You then have to run autoreconf -i to regenerate the configure script. Then if you want to be tidy, you should replace the MD5 sums in the MD5 file.

sed -i 's/.* \*configure$/b0353998496b776117a86b10d9107c0e  *configure/;
    s/.* \*configure.ac$/c4e63e6beff87ac335d1e206e498d728  *configure.ac/' \
    MD5

At this point, tar the lwgeom back up into its tarball, and install from the tarball.

If you are in the lwgeom directory and want to test, you can use (with suitably defined variables)

./configure --with-proj-include=$PROJ_INCLUDE --with-proj-lib=$PROJ_LIB --with-proj-share=$PROJ_SHARE/proj

and check that src/Makevars contains

PKG_LIBS= -L/sw/specials/proj/4.9.2/lib  -lproj -L/sw/specials/geos/3.5.0/lib -lgeos_c

I can turn this into a pull request if the maintainers would like.

This was referenced Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants