6

I tried to install rgdal with configure.args but no luck.

Installed gdal version:

gdal-config --version
1.11.2

ogrinfo --version
GDAL 1.11.2, released 2015/02/10

found gdal binary tools:

ls /usr/bin | grep gdal
gdal2tiles.py
gdal2xyz.py
gdaladdo
gdal_auth.py
gdalbuildvrt
gdal_calc.py
gdalchksum.py
gdalcompare.py
gdal-config
gdal_contour
gdaldem
gdal_edit.py
gdalenhance
gdal_fillnodata.py
gdal_grid
gdalident.py
gdalimport.py
gdalinfo
gdallocationinfo
gdalmanage
gdal_merge.py
gdalmove.py
gdal_polygonize.py
gdal_proximity.py
gdal_rasterize
gdal_retile.py
gdalserver
gdal_sieve.py
gdalsrsinfo
gdaltindex
gdaltransform
gdal_translate
gdalwarp

found proj header files:

ls /usr/include | grep proj
libprojectM
libprojectM-qt
org_proj4_Projections.h
proj_api.h
projects.h

found proj lib files:

ls /usr/lib | grep proj
libproj.a
libprojectM-qt.so
libprojectM-qt.so.1
libprojectM-qt.so.1.10
libprojectM.so
libprojectM.so.2
libprojectM.so.2.1.0
libproj.la
libproj.so
libproj.so.0
libproj.so.0.7.0

installed packages about gdal:

dpkg -l | grep  gdal
ii  gdal-bin                                              1.11.2+dfsg-1~exp2~trusty                           amd64        Geospatial Data Abstraction Library - Utility programs
ii  libgdal-dev                                           1.11.2+dfsg-1~exp2~trusty                           amd64        Geospatial Data Abstraction Library - Development files
ii  libgdal1-dev                                          1.11.2+dfsg-1~exp2~trusty                           all          Geospatial Data Abstraction Library - Transitional package
ii  libgdal1h                                             1.11.2+dfsg-1~exp2~trusty                           amd64        Geospatial Data Abstraction Library
ii  python-gdal                                           1.11.2+dfsg-1~exp2~trusty                           amd64        Python bindings to the Geospatial Data Abstraction Library

dpkg -l | grep  proj
ii  libgeo-proj4-perl                                     1.05-1                                              amd64        PROJ.4 library for cartographic projections
ii  libproj-dev                                           4.8.0-2ubuntu2                                      amd64        Cartographic projection library (development files)
ii  libproj0                                              4.8.0-2ubuntu2                                      amd64        Cartographic projection library
ii  libprojectm-dev                                       2.1.0+dfsg-1build2                                  amd64        Advanced Milkdrop-compatible music visualization library - dev
ii  libprojectm-qt-dev                                    2.1.0+dfsg-1build2                                  amd64        projectM Qt4 (development files)
ii  libprojectm-qt1                                       2.1.0+dfsg-1build2                                  amd64        projectM Qt4 bindings
ii  libprojectm2                                          2.1.0+dfsg-1build2                                  amd64        Advanced Milkdrop-compatible music visualization library
ii  proj-bin                                              4.8.0-2ubuntu2                                      amd64        Cartographic projection library (tools)
ii  proj-data                                             4.8.0-2ubuntu2                                      amd64        Cartographic projection filter and library (datum package)
ii  projectm-data                                         2.1.0+dfsg-1build2                                  all          Advanced Milkdrop-compatible music visualization library - data
ii  xfwm4                                                 4.11.1-2ubuntu2                                     amd64        window manager of the Xfce project

install.packages('rgdal',type='source',
                  configure.args = paste('--with-gdal-config=/usr/bin/gdal-config',
                                         '--with-proj-lib=/usr/lib',
                                         '--with-proj-include=/usr/include') )
Installing package into ‘/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'http://mirrors.ustc.edu.cn/CRAN/src/contrib/rgdal_0.9-2.tar.gz'
Content type 'application/gzip' length 1627386 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: 0.9-2
checking for /usr/bin/svnversion... no
configure: svn revision: 526
configure: gdal-config set to /usr/bin/gdal-config
checking gdal-config exists... yes
checking gdal-config executable... yes
checking gdal-config usability... yes
configure: GDAL: 1.11.2
checking GDAL version >= 1.6.3... yes
checking GDAL version < 2... yes
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking gdal: linking with --libs only... yes
checking GDAL: /usr/share/gdal/1.11/pcs.csv readable... yes
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
checking for pj_init_plus in -lproj... yes
configure: PROJ.4 version: > 4.8.0
/tmp/ccsGVxP9.o: In function `main':
/tmp/RtmpOqwz92/R.INSTALL23317ae38fc4/rgdal/proj_conf_test.c:20: undefined reference to `pj_ctx_fclose'
collect2: error: ld returned 1 exit status
./configure: line 3735: ./proj_conf_test: No such file or directory
checking PROJ.4: epsg found and readable... yes
/tmp/ccaNfCUo.o: In function `main':
/tmp/RtmpOqwz92/R.INSTALL23317ae38fc4/rgdal/proj_conf_test.c:20: undefined reference to `pj_ctx_fclose'
collect2: error: ld returned 1 exit status
./configure: line 3810: ./proj_conf_test: No such file or directory
checking PROJ.4: conus found and readable... yes
configure: Package CPP flags:  -I/usr/include/gdal -I/usr/include
configure: Package LIBS:  -L/usr/lib -lgdal -L/usr/lib -lproj
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include  -I"/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/sp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c OGR_write.cpp -o OGR_write.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include  -I"/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/sp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c gdal-bindings.cpp -o gdal-bindings.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include  -I"/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/sp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include  -I"/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/sp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c local_stubs.c -o local_stubs.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include  -I"/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/sp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c ogr_geom.cpp -o ogr_geom.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include  -I"/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/sp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c ogr_polygons.c -o ogr_polygons.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include  -I"/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/sp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c ogr_proj.cpp -o ogr_proj.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include  -I"/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/sp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c ogrdrivers.cpp -o ogrdrivers.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include  -I"/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/sp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c ogrsource.cpp -o ogrsource.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include  -I"/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/sp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c projectit.cpp -o projectit.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o rgdal.so OGR_write.o gdal-bindings.o init.o local_stubs.o ogr_geom.o ogr_polygons.o ogr_proj.o ogrdrivers.o ogrsource.o projectit.o -L/usr/lib -lgdal -L/usr/lib -lproj -L/usr/lib/R/lib -lR
installing to /home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/rgdal/libs
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/rgdal/libs/rgdal.so':
  /home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/rgdal/libs/rgdal.so: undefined symbol: pj_ctx_fgets
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/rgdal’
Warning in install.packages :
  installation of package ‘rgdal’ had non-zero exit status

EDIT: I have tried install.packages('rgdal') without any configure.args. I got the same error. Now, I am tring to install rgdal with a compiled proj4 4.9.1 and export LD_LIBRARY_PATH to proj4 4.9.1. Unfortunately, it failed again. Here is my new script.sh:

export LD_LIBRARY_PATH=/home/wangchl/R-scripting/R-install/proj-4.9.1/ccc/lib:/usr/lib:$LD_LIBRARY_PATH

sudo R CMD REMOVE  rgdal

R CMD INSTALL rgdal_0.9-2.tar.gz --byte-compile --configure-args='--with-gdal-config=/usr/bin/gdal-config --with-proj-lib=/home/wangchl/R-scripting/R-install/proj-4.9.1/ccc/lib  --with-proj-include=/home/wangchl/R-scripting/R-install/proj-4.9.1/ccc/include  --with-proj-share=/home/wangchl/R-scripting/R-install/proj-4.9.1/ccc/share/proj'

Everything is fine but failed when testing:

installing to /home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/rgdal/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/rgdal/libs/rgdal.so':
  /home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/rgdal/libs/rgdal.so: undefined symbol: pj_ctx_fgets
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/wangchl/R/x86_64-pc-linux-gnu-library/3.2/rgdal’

Update: Finally, I sovled this issue . Firstly, removing proj4-4.8 by apt-get.

sudo apt-get remove libproj-dev

Secondly, adding my compiled proj4-4.9 lib path into a new conf file (such as rgdal.conf) under the path of '/etc/ld.so.conf.d/'.

cd /etc/ld.so.conf.d
sudo touch rgdal.conf
echo 'the lib path of proj4-4.9' | sudo tee -a rgdal.conf 

And then, installing rgdal with configure.args referencing the compiled lib path of proj4-4.9.

export LD_LIBRARY_PATH=the lib path of proj4-4.9:$LD_LIBRARY_PATH

sudo R CMD REMOVE  rgdal

R CMD INSTALL rgdal_0.9-2.tar.gz --byte-compile --configure-args='--with-gdal-config=/usr/bin/gdal-config --with-proj-lib=compiled path of proj4-4.9/lib  --with-proj-include=compiled path of proj4-4.9/include  --with-proj-share=compiled path of proj4-4.9/share/proj'

Right now, everything is fine. But I am failed to install any version of rgdal with proj4-4.8 and default configure.args. I have already cleaned files of proj4 following the suggestion of @Pascal . So I am not sure the exact reason about this issue.

seifer_08ms
  • 375
  • 5
  • 17
  • Do you really need `configure.args`? Required headers seem to be installed in common directories (`/usr/include`, `/usr/lib` and so on). Also, did you try using another mirror? –  May 19 '15 at 08:41
  • I have tried install.packages('rgdal') without any configure.args. I got the same error. I am tring to install rgdal with a compiled proj4 4.9 and export LD_LIBRARY_PATH to proj4 4.9. Unfortunately, it failed again. – seifer_08ms May 19 '15 at 09:15
  • 1
    This might be helpful: https://stat.ethz.ch/pipermail/r-sig-geo/2012-May/014973.html. You may encounter a problem if you have multiple installed version of proj. –  May 19 '15 at 09:21
  • Thanks for @Pascal 's kindly help. Could you provide some solutions? – seifer_08ms May 19 '15 at 09:47
  • 1
    I would recommend to remove proj.4 4.8 and to check whether there is any files (proj, libproj...) remaining in `/usr/bin`, `/usr/include`, `/usr/lib`, as well as in `/usr/local/bin`, `/usr/local/include`, `/usr/local/lib`. Then compile (`make`), install (`make install`) and remove (`make uninstall`) proj.4 4.9. Then finally install proj.4 4.8 with `apt-get`. –  May 19 '15 at 10:30
  • I noticed the messages ' configure: PROJ.4 version: > 4.8.0' . Now, I think the reason is probably that the current version of rgdal doesn't support proj4-4.8. I will test it and let you know – seifer_08ms May 20 '15 at 00:47
  • 1
    I don't think so. My current setup is Ubuntu 14.10 with R version 3.2.0, proj.4 4.8.0-5 and rgdal_0.9-2. And it works. –  May 20 '15 at 01:11
  • Finally, I sovled this issue . Firstly, removing proj4-4.8 by apt-get. Secondly, adding my compiled proj4-4.9 lib path into a new conf file (such as rgdal.conf) and moving it under the path of '/etc/ld.so.conf.d/'. And then, installing rgdal with configure.args referencing the path of proj4-4.9. Right now, everything is fine. But I am failed to install older version of rgdal with proj4-4.8 and default configure.args. – seifer_08ms May 20 '15 at 01:31

2 Answers2

3

Do you have libgdal-dev and libproj-dev installed?

In terminal:

sudo apt-get update && sudo apt-get install libgdal-dev libproj-dev

Then in R try and install rgdal again.

Phil
  • 4,344
  • 2
  • 23
  • 33
  • Yes, gdal 1.11.2 and proj4 4.8.0 are installed by apt-get . – seifer_08ms May 19 '15 at 09:24
  • And I can ensure these with command 'dpkg -l | grep gdal ' and ' dpkg -l | grep proj ' . The installed packages are listed in my question. – seifer_08ms May 19 '15 at 09:26
  • So you have proj.4 4.8 and 4.9 installed? –  May 19 '15 at 09:27
  • Yep my bad, I'd scrolled down in that code block and was looking at the error. I notice on my system I have v 1.10.1 of gdal installed (14.04); could your use of v 1.11.x be causing a problem? – Phil May 19 '15 at 09:31
  • 1
    It probably is a conflict between versions of proj.4, as stated here: https://stat.ethz.ch/pipermail/r-sig-geo/2012-May/014973.html –  May 19 '15 at 09:33
  • I compiled proj4 4.9 before but not sure if I have purged it completely. I just deleted the lib files and headers of proj4 4.9 and installd 4.8 by apt-get. The compiled files are left in their path and should not be active in the system-side. Would you give me some advise to solve the version trouble ? – seifer_08ms May 19 '15 at 09:39
  • Did you try to install `rdal` again? –  May 19 '15 at 09:45
  • Yes, no luck . It seems that there are existing confliction in my system about proj with 4.8 and 4.9 because of not fully uninstall for previous version. – seifer_08ms May 19 '15 at 09:52
  • Sorry I was unable to help you. @Pascal, what's the best way to move these comments somewhere permanent in case someone else has any ideas? – Phil May 19 '15 at 10:10
2

Finally, I sovled this issue . Firstly, removing proj4-4.8 by apt-get.

sudo apt-get remove libproj-dev

Secondly, adding my compiled proj4-4.9 lib path into a new conf file (such as rgdal.conf) under the path of '/etc/ld.so.conf.d/'.

cd /etc/ld.so.conf.d
sudo touch rgdal.conf
echo 'the lib path of proj4-4.9' | sudo tee -a rgdal.conf 

And then, installing rgdal with configure.args referencing the compiled lib path of proj4-4.9.

export LD_LIBRARY_PATH=the lib path of proj4-4.9:$LD_LIBRARY_PATH

sudo R CMD REMOVE  rgdal

R CMD INSTALL rgdal_0.9-2.tar.gz --byte-compile --configure-args='--with-gdal-config=/usr/bin/gdal-config --with-proj-lib=compiled path of proj4-4.9/lib  --with-proj-include=compiled path of proj4-4.9/include  --with-proj-share=compiled path of proj4-4.9/share/proj'

Right now, everything is fine. But I am failed to install any version of rgdal with proj4-4.8 and default configure.args. I have already cleaned files of proj4 following the suggestion of @Pascal . So I am not sure the exact reason about this issue.

seifer_08ms
  • 375
  • 5
  • 17