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

Install Error: proj_conf_test.c:4:28: error: expected ')' before 'const' FILE *pj_open_lib(projCtx, const char *, const char *); #678

Closed
bindatype opened this issue Mar 19, 2018 · 8 comments

Comments

@bindatype
Copy link

Can't install sf -- the error looks like:

DEPS SATISFIED ARE:

  • udunits/2.2.25
  • proj.4/4.7
  • gdal/gcc/2.2.0

SETUP:

library(rgdal)
Loading required package: sp
rgdal: version: 1.2-13, (SVN revision 686)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 2.2.0, released 2017/04/28
 Path to GDAL shared files: /c1/apps/gdal/gcc/2.2.0/share/gdal
 Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470]
 Path to PROJ.4 shared files: (autodetected)
 Linking to sp version: 1.2-5

INSTALL & ERROR:

install.packages("sf",configure.args='--with-udunits2-lib=/c1/libs/udunits/lib')
...
proj_conf_test.c:4:28: error: expected ')' before 'const'
 FILE *pj_open_lib(projCtx, const char *, const char *);
                            ^
proj_conf_test.c: In function 'main':
proj_conf_test.c:13:5: error: unknown type name 'projCtx'
     projCtx ctx;
     ^
proj_conf_test.c:14:5: warning: implicit declaration of function 'pj_get_default_ctx' [-Wimplicit-function-declaration]
     ctx = pj_get_default_ctx();
     ^
proj_conf_test.c:15:5: warning: implicit declaration of function 'pj_open_lib' [-Wimplicit-function-declaration]
     fp = pj_open_lib(ctx, "epsg", "rb");
     ^
proj_conf_test.c:15:8: warning: assignment makes pointer from integer without a cast
     fp = pj_open_lib(ctx, "epsg", "rb");
        ^
470
checking PROJ.4: epsg found and readable... yes
proj_conf_test.c:4:28: error: expected ')' before 'const'
 FILE *pj_open_lib(projCtx, const char *, const char *);
                            ^
proj_conf_test.c: In function 'main':
proj_conf_test.c:13:5: error: unknown type name 'projCtx'
     projCtx ctx;
     ^
proj_conf_test.c:14:5: warning: implicit declaration of function 'pj_get_default_ctx' [-Wimplicit-function-declaration]
     ctx = pj_get_default_ctx();
     ^
proj_conf_test.c:15:5: warning: implicit declaration of function 'pj_open_lib' [-Wimplicit-function-declaration]
     fp = pj_open_lib(ctx, "conus", "rb");
     ^
proj_conf_test.c:15:8: warning: assignment makes pointer from integer without a cast
     fp = pj_open_lib(ctx, "conus", "rb");
        ^
./configure: line 3850: ./proj_conf_test: No such file or directory
checking PROJ.4: conus found and readable... yes
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘sf’

Any idea how to resolve this issue?

@edzer
Copy link
Member

edzer commented Mar 19, 2018

You need to install development versions of the GEOS library. I also think that sf will want you to use proj 4.8.0 or later. Look at the README for instructions for various platforms; you didn't reveal yours.

@rsbivand
Copy link
Member

Note that your declared 4.7.1 is not in https://download.osgeo.org/proj/, and although it is nine years ago, I remember a numbering snafu. The sf error looks odd, because configure.in doesn't use Ctx for versions <= 4.8.0. Do you have two versions of proj sorting in different order at build time and run time?

@bindatype
Copy link
Author

bindatype commented Mar 26, 2018

Hi folks, sorry for the long delay. I feel a bit silly for not loading the geos 3.6 module. When I prepared this issue report I forgot to load it which does change the error so thanks for pointing that out! Nevertheless, problem with Ctx that we're seeing is:

proj.cpp: In function ‘bool CPL_have_datum_files(SEXP)’:
proj.cpp:45:5: error: ‘projCtx’ was not declared in this scope
     projCtx ctx;
     ^
proj.cpp:46:5: error: ‘ctx’ was not declared in this scope
     ctx = pj_get_default_ctx();
     ^
proj.cpp:46:30: error: ‘pj_get_default_ctx’ was not declared in this scope
     ctx = pj_get_default_ctx();
                              ^
proj.cpp:47:40: error: ‘pj_open_lib’ was not declared in this scope
     fp = pj_open_lib(ctx, "conus", "rb");
                                        ^
make: *** [proj.o] Error 1
ERROR: compilation failed for package ‘sf’

Regarding Roger's suggestion that there may be two versions of proj we only have the one version, 4.7.1.

Lastly, the reason we're using an older version of proj4 is due to an rgdal 1.2-13 dependency that makes a reference to #include <projects.h> although project.h was removed in proj 4.8.0 as explained here.

@edzer
Copy link
Member

edzer commented Mar 26, 2018

System requirement of sf is: Proj.4 >= 4.8.0 and GDAL >= 2.0.0 (although, erroneously, 0.6-1 CRAN release requires 2.1,but this has been corrected in the dev version.

@edzer
Copy link
Member

edzer commented Mar 26, 2018

See also #689.

@edzer edzer closed this as completed Mar 26, 2018
@bindatype
Copy link
Author

bindatype commented Apr 1, 2018

I thank you for kindly looking into this issue and your suggestions however I wish you had not marked this issue as closed. I've done as you've said and successfully built sf with Proj.4 = 4.8.0 but, as I said before, this causes rgdal to fail to install. I should point out that rgdal requires proj >= 4.4.9, not >=4.8.0 so right away one can see how incompatibilities can creep in (due to different version dependencies) for those folks like us who need to run sf and rgdal in the same environment.

As discussed here, projects.h is no longer included with Proj.4 and so how does one run sf which requires proj.4 >= 4.8.0 with rgdal which makes a call to projects.h which is no longer found in proj.4 >= 4.8.0?

Note that rgdal installs just fine with proj.4/4.7 because projects.h is included therein.

> install.packages("rgdal")
trying URL 'https://mirrors.nics.utk.edu/cran/src/contrib/rgdal_1.2-18.tar.gz'
Content type 'application/x-gzip' length 1650578 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgdal: 1.2-18
checking for /usr/bin/svnversion... yes
configure: svn revision: 718
checking for gdal-config... /c1/apps/gdal/gcc/2.2.0/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.0
checking GDAL version >= 1.6.3... yes
checking gdal: linking with --libs only... yes
checking GDAL: /c1/apps/gdal/gcc/2.2.0/share/gdal/pcs.csv readable... yes
configure: -g -O2 -fPIC -I/c1/apps/pcre/8.41/include -I/c1/apps/zlib/include -I/c1/apps/bzip2/1.0.6/include -I/c1/apps/xz/5.2.3/include -I/c1/apps/curl/7.51.0/include  -I/c1/apps/gdal/gcc/2.2.0/include
checking proj_api.h presence and usability... yes
checking PROJ.4 version: ... 4.8.0
checking PROJ.4: epsg found and readable... yes
checking PROJ.4: conus found and readable... no
Note: proj/conus not found
No support available in PROJ4 for NAD grid datum transformations
If required, consider re-installing from source with the contents
of proj-datumgrid-1.<latest>.zip from http://download.osgeo.org/proj/ in nad/.
configure: Package CPP flags:  -I/c1/apps/gdal/gcc/2.2.0/include
configure: Package LIBS:  -L/c1/apps/gdal/gcc/2.2.0/lib -lgdal -lproj
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I/c1/apps/R/3.4.2/lib64/R/include -DNDEBUG -I/c1/apps/gdal/gcc/2.2.0/include -I"/c1/apps/R/3.4.2/lib64/R/library/sp/include" -I/usr/local/include   -fpic  -g -O2 -c OGR_write.cpp -o OGR_write.o
g++ -std=gnu++11 -I/c1/apps/R/3.4.2/lib64/R/include -DNDEBUG -I/c1/apps/gdal/gcc/2.2.0/include -I"/c1/apps/R/3.4.2/lib64/R/library/sp/include" -I/usr/local/include   -fpic  -g -O2 -c gdal-bindings.cpp -o gdal-bindings.o
gcc -std=gnu99 -I/c1/apps/R/3.4.2/lib64/R/include -DNDEBUG -I/c1/apps/gdal/gcc/2.2.0/include -I"/c1/apps/R/3.4.2/lib64/R/library/sp/include" -I/usr/local/include   -fpic  -g -O2 -fPIC -I/c1/apps/pcre/8.41/include -I/c1/apps/zlib/include -I/c1/apps/bzip2/1.0.6/include -I/c1/apps/xz/5.2.3/include -I/c1/apps/curl/7.51.0/include  -c init.c -o init.o
gcc -std=gnu99 -I/c1/apps/R/3.4.2/lib64/R/include -DNDEBUG -I/c1/apps/gdal/gcc/2.2.0/include -I"/c1/apps/R/3.4.2/lib64/R/library/sp/include" -I/usr/local/include   -fpic  -g -O2 -fPIC -I/c1/apps/pcre/8.41/include -I/c1/apps/zlib/include -I/c1/apps/bzip2/1.0.6/include -I/c1/apps/xz/5.2.3/include -I/c1/apps/curl/7.51.0/include  -c inverser.c -o inverser.o
inverser.c:4:22: fatal error: projects.h: No such file or directory
 #include <projects.h>
                      ^
compilation terminated.
make: *** [inverser.o] Error 1
ERROR: compilation failed for package ‘rgdal’
* removing ‘/c1/apps/R/3.4.2/lib64/R/library/rgdal’

The downloaded source packages are in
	‘/home/maclach/.Rtmp/Rtmpi2fLXJ/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("rgdal") :
  installation of package ‘rgdal’ had non-zero exit status

@rsbivand
Copy link
Member

rsbivand commented Apr 2, 2018

This continues to be your problem. My guess is that PROJ.4 was installed from a package, not source. You have certainly omitted the NAD grids, and probably other subsidiary packages. You have not stated your platform (output of sessionInfo()). I guess a very old Centos or RHEL, but it could be an equally neglected Ubuntu or Debian. You should always keep GEOS, GDAL and PROJ as up to date as possible, as newer versions include not only bug fixes, but also security fixes where appropriate.

The only valid reason for using older versions where possible is for reproducing old results, you should ensure that your OS and underlying software are appropriate. For rgdal, you can still use older external dependencies because it has been around for a long time. <projects.h> is needed to check for the absence of inverse projections, but was introduced relatively recently.

@bindatype
Copy link
Author

bindatype commented Apr 2, 2018

Thank you for your patience and quick reply. All software for users that is installed on our CentOS 6.7 cluster is installed from source.

I think we may be talking across one another so allow me to simplify and hopefully refocus. Our users require

  1. sf
  2. lwgeom
  3. rgdal

I can install 1 and 2 or install 3 but that requires me to switch versions on Proj.4, otherwise one gets the sorts of errors that I've been enumerating.

I'm simply trying to find the means to run all three packages simultaneously that doesn't require us to load environment modules for Proj.4 4.7.1 (as required by rgdal) and Proj.4 4.8.0 (as required by sf and lwgeom). If, for example, you say there is no other way around it and we have to maintain both versions of Proj.4 to support sf and rgdal then so be it. However, what I'm asking you is there a more nuanced way to install and run these packages that doesn't require multiple versions of Proj.4 which can lead to conflicts such as including both dynamic library versions in LD_LIBRARY_PATH, for example or the install errors I've been hitting?

The software stack we are running, including version numbers, is:
GDAL 2.2.0
GEOS 3.6
R 3.4.2
Proj.4 4.8.0 (or 4.7.1 if we need rgdal).

Thanks again for your attention to this issue.

For reference, the output of sessionInfo() is given below.

> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS release 6.7 (Final)

Matrix products: default
BLAS: /c1/apps/R/3.4.2/lib64/R/lib/libRblas.so
LAPACK: /c1/apps/R/3.4.2/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_3.4.2

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