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

undefined symbol: libiconv #299

Closed
mfansler opened this issue Jul 16, 2017 · 2 comments
Closed

undefined symbol: libiconv #299

mfansler opened this issue Jul 16, 2017 · 2 comments

Comments

@mfansler
Copy link

Problem

Ran: install.packages("tidyverse")

Result: haven compiles, but during the step to test package loading it yields

...
 ** testing if installed package can be loaded
 Error in dyn.load(file, DLLpath = DLLpath, ...) :
   unable to load shared object '/home/username/.local/lib/R-3.3.3/haven/libs/haven.so':
   /home/username/.local/lib/R-3.3.3/haven/libs/haven.so: undefined symbol: libiconv
 Error: loading failed
 Execution halted
 ERROR: loading failed
 * removing ‘/home/username/.local/lib/R-3.3.3/haven’

which results in failed installation.

System Info

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

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

This is on a cluster account (no root privileges). Non-R libraries that I require, such as libiconv are built and installed into a local path, and that path is included in LD_LIBRARY_PATH. I have verified that Sys.getenv("LD_LIBRARY_PATH") includes the path to libiconv.so.

Expected behavior

R should use LD_LIBRARY_PATH environment variable to resolve linked libraries, in this case libiconv.

Attempted workarounds

  1. Manually pre-load libiconv

    dyn.load("/home/username/.local/lib/libiconv.so")
    is.loaded("libiconv") ## [1] TRUE
    install.packages("haven")
    
  2. Create symlink to libiconv.so in R library path.

Both attempts resulted in the same error message being encountered when the installer tests loading.

Additional notes

During compilation, the gcc/g++ calls do not include a -L/home/username/.local/lib flag, which is what I would expect if LD_LIBRARY_PATH was being used.

Same thing happens for readxl package, so this is not a haven-specific issue. I'm mainly hoping that someone here has an idea as to why this linked library isn't being found and how to properly configure R to find it.

@mfansler
Copy link
Author

After building from source and inspecting the shared object

> ldd haven/src/haven.so
    linux-vdso.so.1 =>  (0x00007fff03ce4000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00002b09d32f8000)
    libm.so.6 => /lib64/libm.so.6 (0x00002b09d3601000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002b09d3903000)
    libc.so.6 => /lib64/libc.so.6 (0x00002b09d3b19000)
    /lib64/ld-linux-x86-64.so.2 (0x00002b09d2b97000)

I noticed that it wasn't even linking to libiconv. Rerunning the shared object creation step, with the added flag of -liconv seemed to fix the issue:

g++ -shared -L/usr/local/lib64 -liconv -o haven.so tagged_na.o ...

I could then install, without issue

R CMD INSTALL haven

Previously I was under the impression that I had a strange configuration issue (still probably the case!), but now it seems that haven and readxl are not correctly linking to this dependency.

Why doesn't the package link libiconv on its own? I'm not a package developer, so I know next to nothing of the underlying mechanics for package installation.

@mfansler
Copy link
Author

mfansler commented Jul 21, 2017

Personally, I have this issue resolved, and it appears that it is a very atypical situation, so I'm closing this thread.

If it comes up for others, adding PKG_LIBS=-liconv to the src/Makevars file will explicitly tell the linker to include libiconv and allow for successful installation from source.

@lock lock bot locked and limited conversation to collaborators Jun 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant