Discussion:
[Rcpp-devel] Getting different build commands on Linux vs. Mac OS
Evan Biederstedt
2018-04-30 10:48:31 UTC
Permalink
Dear list

I have the following R package which is interacting with a C library via
Rcpp and extern. At some point, the goal is to combine these....but I'm
trying this with baby steps.

R package with C++ wrapper:
https://github.com/d-lo/bambi

The C library:
https://github.com/d-lo/bamdb

When I try to install the R package on Linux, the Makevars appears use the
compiler g++, and it installs correctly:


```
Installing package into '/home/username/R/x86_64-pc-linux-gnu-library/3.2'
(as 'lib' is unspecified)
* installing *source* package 'bambi' ...
** libs
g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/
-I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/
-I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g -c bambi.cpp -o bambi.o
g++ -std=c++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions
-Wl,-z,relro -o bambi.so RcppExports.o bambi.o -lbamdb -llmdb -lhts
-L/usr/lib/R/lib -lR
installing to /home/username/R/x86_64-pc-linux-gnu-library/3.2/bambi/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (bambi)
library(bambi)
```

Here's what I see when I do the same on Mac OS. It uses clang++, and has
entirely different build commands:

```

* installing to library
‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’

* installing *source* package ‘bambi’ ...

** libs

clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
-I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o
RcppExports.o

clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
-I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -fPIC -Wall -g -O2 -c bambi.cpp -o bambi.o

clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
-I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -fPIC -Wall -g -O2 -c rcpp_hello_world.cpp -o
rcpp_hello_world.o

clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined
dynamic_lookup -single_module -multiply_defined suppress
-L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o
bambi.so RcppExports.o bambi.o rcpp_hello_world.o
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
-Wl,CoreFoundation

installing to
/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs

** R

** preparing package for lazy loading

** help

*** installing help indices

** building package indices

** testing if installed package can be loaded

Error: package or namespace load failed for ‘bambi’ in dyn.load(file,
DLLpath = DLLpath, ...):

unable to load shared object
'/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so':

dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so,
6): Symbol not found: _get_bam_rows

Referenced from:
/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so

Expected in: flat namespace

in
/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so

Error: loading failed

Execution halted

ERROR: loading failed

* removing
‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi’

```

Why is there this discrepancy? How do I direct the Makevars to use g++ and
give me the "correct" build as I see on Linux? `CXX=g++` or
`CXX=/usr/local/bin/g++` doesn't appear to work.
Ralf Stubner
2018-04-30 13:54:52 UTC
Permalink
How do I direct the Makevars to use g++ and give me the "correct" build
as I see on Linux? `CXX=g++` or `CXX=/usr/local/bin/g++` doesn't appear
to work. 
Quoting Duncan Murdoch in
According to section 1.2.1 "Using Makevars" in Writing R Extensions,
R_HOME/etcR_ARCH/Makeconf is included after Makevars, so what you're
seeing is by design. I believe this is so that packages are built with
tools compatible with those that built R. (Remember, packages are
designed for distribution to diverse systems.)
So you might change various flags within src/Makevars via for example
PKG_CXXFLAGS, but you cannot overwrite CXXFLAGS or CXX itself. And there
is no PKG_CXX. You can change the used compiler for *your* system via
~/.R/Makevars, though. From my point of view that is a (short-time)
workaround only. You have to figure out why clang does not like your
package/library.

Greetings
Ralf
--
Ralf Stubner
Senior Software Engineer / Trainer

daqana GmbH
Dortustraße 48
14467 Potsdam

T: +49 331 23 70 81 66
F: +49 331 23 70 81 67
M: +49 162 20 91 196
Mail: ***@daqana.com

Sitz: Potsdam
Register: AG Potsdam HRB 27966 P
Ust.-IdNr.: DE300072622
GeschÀftsfÌhrer: Prof. Dr. Dr. Karl-Kuno Kunze
Keith O'Hara
2018-04-30 14:34:48 UTC
Permalink
Looks like your PKG_LIBS arguments are ignored/overwritten on the Mac build; ‘bambi.so’ appears to be missing objects contained in -lbamdb, hence the load error.

Keith
Post by Evan Biederstedt
Dear list
I have the following R package which is interacting with a C library via Rcpp and extern. At some point, the goal is to combine these....but I'm trying this with baby steps.
https://github.com/d-lo/bambi
https://github.com/d-lo/bamdb
```
Installing package into '/home/username/R/x86_64-pc-linux-gnu-library/3.2'
(as 'lib' is unspecified)
* installing *source* package 'bambi' ...
** libs
g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/ -I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/ -I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c bambi.cpp -o bambi.o
g++ -std=c++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o bambi.so RcppExports.o bambi.o -lbamdb -llmdb -lhts -L/usr/lib/R/lib -lR
installing to /home/username/R/x86_64-pc-linux-gnu-library/3.2/bambi/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (bambi)
library(bambi)
```
```
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
* installing *source* package ‘bambi’ ...
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c bambi.cpp -o bambi.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c rcpp_hello_world.cpp -o rcpp_hello_world.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o bambi.so RcppExports.o bambi.o rcpp_hello_world.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so, 6): Symbol not found: _get_bam_rows
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so
Expected in: flat namespace
in /Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi’
```
Why is there this discrepancy? How do I direct the Makevars to use g++ and give me the "correct" build as I see on Linux? `CXX=g++` or `CXX=/usr/local/bin/g++` doesn't appear to work.
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Dirk Eddelbuettel
2018-04-30 15:27:41 UTC
Permalink
On 30 April 2018 at 06:48, Evan Biederstedt wrote:
| Dear list
|
| I have the following R package which is interacting with a C library via
| Rcpp and extern. At some point, the goal is to combine these....but I'm
| trying this with baby steps.
|
| R package with C++ wrapper:
| https://github.com/d-lo/bambi

Ok, so src/Makevars wants three libraries:

PKG_LIBS= -lbamdb -llmdb -lhts

|
| The C library:
| https://github.com/d-lo/bamdb
|
| When I try to install the R package on Linux, the Makevars appears use the
| compiler g++, and it installs correctly:
|
|
| ```
| Installing package into '/home/username/R/x86_64-pc-linux-gnu-library/3.2'
| (as 'lib' is unspecified)
| * installing *source* package 'bambi' ...
| ** libs
| g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/
| -I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2
| -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
| -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
| g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/
| -I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2
| -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
| -D_FORTIFY_SOURCE=2 -g -c bambi.cpp -o bambi.o
| g++ -std=c++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions
| -Wl,-z,relro -o bambi.so RcppExports.o bambi.o -lbamdb -llmdb -lhts
| -L/usr/lib/R/lib -lR

and here we get them as libbamdb.so, liblmdb.so, libhts.so are all system
level libraries and (I guess) 'sudo ldconfig -p' shows them. Linking works,
and they are found as the package loads.

| installing to /home/username/R/x86_64-pc-linux-gnu-library/3.2/bambi/libs
| ** R
| ** preparing package for lazy loading
| ** help
| *** installing help indices
| ** building package indices
| ** testing if installed package can be loaded
| * DONE (bambi)
| > library(bambi)
| ```
|
| Here's what I see when I do the same on Mac OS. It uses clang++, and has
| entirely different build commands:
|
| ```
|
| * installing to library
| ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
|
| * installing *source* package ‘bambi’ ...
|
| ** libs
|
| clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
| -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
| -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o
| RcppExports.o
|
| clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
| -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
| -I/usr/local/include -fPIC -Wall -g -O2 -c bambi.cpp -o bambi.o
|
| clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
| -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
| -I/usr/local/include -fPIC -Wall -g -O2 -c rcpp_hello_world.cpp -o
| rcpp_hello_world.o
|
| clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined
| dynamic_lookup -single_module -multiply_defined suppress
| -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o
| bambi.so RcppExports.o bambi.o rcpp_hello_world.o
| -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
| -Wl,CoreFoundation

I think they should show up here too, but they do not.

Are the libraries installed on the macOS box? Could you compile and link a
trivial test program against them?

Dirk


| installing to
| /Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs
|
| ** R
|
| ** preparing package for lazy loading
|
| ** help
|
| *** installing help indices
|
| ** building package indices
|
| ** testing if installed package can be loaded
|
| Error: package or namespace load failed for ‘bambi’ in dyn.load(file,
| DLLpath = DLLpath, ...):
|
| unable to load shared object
| '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so':
|
| dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so,
| 6): Symbol not found: _get_bam_rows
|
| Referenced from:
| /Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so
|
| Expected in: flat namespace
|
| in
| /Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi/libs/bambi.so
|
| Error: loading failed
|
| Execution halted
|
| ERROR: loading failed
|
| * removing
| ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi’
|
| ```
|
| Why is there this discrepancy? How do I direct the Makevars to use g++ and
| give me the "correct" build as I see on Linux? `CXX=g++` or
| `CXX=/usr/local/bin/g++` doesn't appear to work.
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-***@lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Evan Biederstedt
2018-04-30 19:01:19 UTC
Permalink
Hi all

Thank you for the responses.

@Keith
Post by Keith O'Hara
Looks like your PKG_LIBS arguments are ignored/overwritten on the Mac
build; ‘bambi.so’ appears to be missing objects contained in -lbamdb, hence
the load error.

Yes, it's odd.

@Dirk
Post by Keith O'Hara
Are the libraries installed on the macOS box?
When I build bamdb, CMake checks for the required, which corresponds to
what I see

https://github.com/d-lo/bamdb

```

-- Detecting CXX compile features - done

-- Found CK

-- Found ZLIB: /usr/local/lib/libz.dylib (found version "1.2.11")

-- Found HTSlib

-- Found LMDB

-- Configuring done

-- Generating done

-- Build files have been written to: /Users/ebiederstedt/bamdb/build

```
With `sudo make install`, I think `bamdb` should be accessible via `-lbamdb`

```

$ sudo make install

Password:

[ 50%] Built target bamdb

[100%] Built target libbamdb

Install the project...

-- Install configuration: ""

-- Installing: /usr/local/bin/bamdb

-- Up-to-date: /usr/local/include/bamdb

-- Up-to-date: /usr/local/include/bamdb/bam_api.h

-- Up-to-date: /usr/local/include/bamdb/bam_lmdb.h

-- Up-to-date: /usr/local/include/bamdb/bamdb.h

-- Installing: /usr/local/lib/libbamdb.dylib
```

It's very odd these PKG_LIBS are ignored though....
Post by Keith O'Hara
Could you compile and link a trivial test program against them?
I think this is the next step...

@Ralf
Post by Keith O'Hara
You can change the used compiler for *your* system via ~/.R/Makevars,
though. From my point of view that is a (short-time) workaround only. You
have to figure out why clang does not like your package/library.

I've yet to test changing the compiler in ~/.R/Makevars. However, it's not
clear to me why this would be a short-term solution. Could you clarify why
using g++ instead of clang would be a problem gong forwards?
Post by Keith O'Hara
| Dear list
|
| I have the following R package which is interacting with a C library via
| Rcpp and extern. At some point, the goal is to combine these....but I'm
| trying this with baby steps.
|
| https://github.com/d-lo/bambi
PKG_LIBS= -lbamdb -llmdb -lhts
|
| https://github.com/d-lo/bamdb
|
| When I try to install the R package on Linux, the Makevars appears use the
|
|
| ```
| Installing package into '/home/username/R/x86_64-pc-
linux-gnu-library/3.2'
| (as 'lib' is unspecified)
| * installing *source* package 'bambi' ...
| ** libs
| g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/
| -I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2
| -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
| -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
| g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/
| -I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2
| -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
| -D_FORTIFY_SOURCE=2 -g -c bambi.cpp -o bambi.o
| g++ -std=c++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions
| -Wl,-z,relro -o bambi.so RcppExports.o bambi.o -lbamdb -llmdb -lhts
| -L/usr/lib/R/lib -lR
and here we get them as libbamdb.so, liblmdb.so, libhts.so are all system
level libraries and (I guess) 'sudo ldconfig -p' shows them. Linking works,
and they are found as the package loads.
| installing to /home/username/R/x86_64-pc-linux-gnu-library/3.2/bambi/
libs
| ** R
| ** preparing package for lazy loading
| ** help
| *** installing help indices
| ** building package indices
| ** testing if installed package can be loaded
| * DONE (bambi)
| > library(bambi)
| ```
|
| Here's what I see when I do the same on Mac OS. It uses clang++, and has
|
| ```
|
| * installing to library
| ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
|
| * installing *source* package ‘bambi’ ...
|
| ** libs
|
| clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
| -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/
include"
| -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o
| RcppExports.o
|
| clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
| -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/
include"
| -I/usr/local/include -fPIC -Wall -g -O2 -c bambi.cpp -o bambi.o
|
| clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
| -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/
include"
| -I/usr/local/include -fPIC -Wall -g -O2 -c rcpp_hello_world.cpp -o
| rcpp_hello_world.o
|
| clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined
| dynamic_lookup -single_module -multiply_defined suppress
| -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o
| bambi.so RcppExports.o bambi.o rcpp_hello_world.o
| -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
| -Wl,CoreFoundation
I think they should show up here too, but they do not.
Are the libraries installed on the macOS box? Could you compile and link a
trivial test program against them?
Dirk
| installing to
| /Library/Frameworks/R.framework/Versions/3.4/
Resources/library/bambi/libs
|
| ** R
|
| ** preparing package for lazy loading
|
| ** help
|
| *** installing help indices
|
| ** building package indices
|
| ** testing if installed package can be loaded
|
| Error: package or namespace load failed for ‘bambi’ in dyn.load(file,
|
| unable to load shared object
| '/Library/Frameworks/R.framework/Versions/3.4/
|
| dlopen(/Library/Frameworks/R.framework/Versions/3.4/
Resources/library/bambi/libs/bambi.so,
| 6): Symbol not found: _get_bam_rows
|
| /Library/Frameworks/R.framework/Versions/3.4/
Resources/library/bambi/libs/bambi.so
|
| Expected in: flat namespace
|
| in
| /Library/Frameworks/R.framework/Versions/3.4/
Resources/library/bambi/libs/bambi.so
|
| Error: loading failed
|
| Execution halted
|
| ERROR: loading failed
|
| * removing
| ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi’
|
| ```
|
| Why is there this discrepancy? How do I direct the Makevars to use g++ and
| give me the "correct" build as I see on Linux? `CXX=g++` or
| `CXX=/usr/local/bin/g++` doesn't appear to work.
| _______________________________________________
| Rcpp-devel mailing list
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
Dirk Eddelbuettel
2018-04-30 20:34:53 UTC
Permalink
Evan,

Could something be amiss with your macOS machine? Can you install other
packages without issues on it?

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Ralf Stubner
2018-04-30 21:33:36 UTC
Permalink
@Ralf
You can change the used compiler for *your* system via ~/.R/Makevars, though. From my point of view that is a (short-time) workaround only. You have to figure out why clang does not like your package/library.
I've yet to test changing the compiler in ~/.R/Makevars. However, it's not clear to me why this would be a short-term solution. Could you clarify why using g++ instead of clang would be a problem gong forwards?
Because clang is the default compiler for R on MacOS. So you would make it difficult for other people (let alone CRAN) to make use of the package. However, I think there is something wrong about your macOS machine. I have just tried to compile your package on a macOS machine that I have access to, and I got quite different results:

$ R CMD INSTALL bambi_1.0.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
* installing *source* package ‘bambi’ ...
** libs
/usr/local/clang4/bin/clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
/usr/local/clang4/bin/clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c bambi.cpp -o bambi.o
bambi.cpp:7:14: fatal error: 'bam_lmdb.h' file not found
#include "bam_lmdb.h"
^~~~~~~~~~~~
1 error generated.
make: *** [bambi.o] Error 1
ERROR: compilation failed for package ‘bambi’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/bambi’

I had not installed the necessary C library, so unsurprisingly the compilation step already failed. What I find interesting is that in my case "-std=gnu++11“ and "-I../inst/include/" are present in the command line options for clang++. These are also missing from what you quoted and are also a consequence of src/Makevars. It almost looks as if this file got lost on your macOS box …

Greetings
Ralf
Evan Biederstedt
2018-04-30 21:42:53 UTC
Permalink
@Ralf
Post by Ralf Stubner
I had not installed the necessary C library, so unsurprisingly the
compilation step already failed. What I find interesting is that in my case
"-std=gnu++11“ and "-I../inst/include/" are present in the command line
options for clang++. These are also missing from what you quoted and are
also a consequence of src/Makevars. It almost looks as if this file got
lost on your macOS box 


Interesting....I'm not sure what to make of this of course, but it would be
interesting if it was only happening on this macbook. Perhaps OS version or
brew could be to blame? I'm not sure what else would be "special" about
this macbook....
Post by Ralf Stubner
Am 30.04.2018 um 21:01 schrieb Evan Biederstedt <
@Ralf
Post by Keith O'Hara
You can change the used compiler for *your* system via ~/.R/Makevars,
though. From my point of view that is a (short-time) workaround only. You
have to figure out why clang does not like your package/library.
I've yet to test changing the compiler in ~/.R/Makevars. However, it's
not clear to me why this would be a short-term solution. Could you clarify
why using g++ instead of clang would be a problem gong forwards?
Because clang is the default compiler for R on MacOS. So you would make it
difficult for other people (let alone CRAN) to make use of the package.
However, I think there is something wrong about your macOS machine. I have
just tried to compile your package on a macOS machine that I have access
$ R CMD INSTALL bambi_1.0.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/
Resources/library’
* installing *source* package ‘bambi’ ...
** libs
/usr/local/clang4/bin/clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I../inst/include/ -I"/Library/Frameworks/R.
framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o
RcppExports.o
/usr/local/clang4/bin/clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I../inst/include/ -I"/Library/Frameworks/R.
framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -fPIC -Wall -g -O2 -c bambi.cpp -o bambi.o
bambi.cpp:7:14: fatal error: 'bam_lmdb.h' file not found
#include "bam_lmdb.h"
^~~~~~~~~~~~
1 error generated.
make: *** [bambi.o] Error 1
ERROR: compilation failed for package ‘bambi’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/
Resources/library/bambi’
I had not installed the necessary C library, so unsurprisingly the
compilation step already failed. What I find interesting is that in my case
"-std=gnu++11“ and "-I../inst/include/" are present in the command line
options for clang++. These are also missing from what you quoted and are
also a consequence of src/Makevars. It almost looks as if this file got
lost on your macOS box 

Greetings
Ralf
Ralf Stubner
2018-05-01 05:44:07 UTC
Permalink
@Ralf
I had not installed the necessary C library, so unsurprisingly the compilation step already failed. What I find interesting is that in my case "-std=gnu++11“ and "-I../inst/include/" are present in the command line options for clang++. These are also missing from what you quoted and are also a consequence of src/Makevars. It almost looks as if this file got lost on your macOS box 

Interesting....I'm not sure what to make of this of course, but it would be interesting if it was only happening on this macbook. Perhaps OS version or brew could be to blame? I'm not sure what else would be "special" about this macbook....
On my side that would be
• macOS high Sierra
• CRAN R 3.4.4
• clang and gfortran as recommended by CRAN
• brew is installed but I do not see how it enters the picture

Greetings
Ralf
Evan Biederstedt
2018-05-01 07:06:05 UTC
Permalink
Maybe my Mac OS needs updating...possibly something with XCode, but it's
not clear how...

--- mac OS Sierra 10.12.6
--- CRAN R 3.4.3
---clang & gfortran

$ clang --version

Apple LLVM version 9.0.0 (clang-900.0.39.2)

Target: x86_64-apple-darwin16.7.0

Thread model: posix

InstalledDir: /Library/Developer/CommandLineTools/usr/bin


$ gfortran --version

GNU Fortran (GCC) 7.1.0

Copyright (C) 2017 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


I will update once I have access to and try this on several other mac boxes
with different specs..

Thank you to everyone for the help.
Am 30.04.2018 um 23:42 schrieb Evan Biederstedt <
@Ralf
Post by Ralf Stubner
I had not installed the necessary C library, so unsurprisingly the
compilation step already failed. What I find interesting is that in my case
"-std=gnu++11“ and "-I../inst/include/" are present in the command line
options for clang++. These are also missing from what you quoted and are
also a consequence of src/Makevars. It almost looks as if this file got
lost on your macOS box 

Interesting....I'm not sure what to make of this of course, but it would
be interesting if it was only happening on this macbook. Perhaps OS version
or brew could be to blame? I'm not sure what else would be "special" about
this macbook....
On my side that would be
• macOS high Sierra
• CRAN R 3.4.4
• clang and gfortran as recommended by CRAN
• brew is installed but I do not see how it enters the picture
Greetings
Ralf
Evan Biederstedt
2018-05-01 07:07:40 UTC
Permalink
I would add, I think clang and gfortran are working correctly, as these are
required for `install.packages('RcppArmadillo')` to install properly.
Post by Evan Biederstedt
Maybe my Mac OS needs updating...possibly something with XCode, but it's
not clear how...
--- mac OS Sierra 10.12.6
--- CRAN R 3.4.3
---clang & gfortran
$ clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gfortran --version
GNU Fortran (GCC) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I will update once I have access to and try this on several other mac
boxes with different specs..
Thank you to everyone for the help.
Am 30.04.2018 um 23:42 schrieb Evan Biederstedt <
@Ralf
Post by Ralf Stubner
I had not installed the necessary C library, so unsurprisingly the
compilation step already failed. What I find interesting is that in my case
"-std=gnu++11“ and "-I../inst/include/" are present in the command line
options for clang++. These are also missing from what you quoted and are
also a consequence of src/Makevars. It almost looks as if this file got
lost on your macOS box 

Interesting....I'm not sure what to make of this of course, but it would
be interesting if it was only happening on this macbook. Perhaps OS version
or brew could be to blame? I'm not sure what else would be "special" about
this macbook....
On my side that would be
• macOS high Sierra
• CRAN R 3.4.4
• clang and gfortran as recommended by CRAN
• brew is installed but I do not see how it enters the picture
Greetings
Ralf
Keith O'Hara
2018-05-01 07:45:31 UTC
Permalink
Unless I'm mistaken, neither are required to install binary packages. Can you check your *source* build setup; try:

curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.500.0.tar.gz
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz

If that goes through without a hitch then it's probably a package issue. Are you using RStudio? Check your build directory for any .Rprofile or .Renviron files, and also check ~/.R/Makevars for errors.

If you can list the required libraries for bamdb, I'm happy to try a build on my end. (I'm lazy to go through the CMake list :-))

Keith
I would add, I think clang and gfortran are working correctly, as these are required for `install.packages('RcppArmadillo')` to install properly.
Maybe my Mac OS needs updating...possibly something with XCode, but it's not clear how...
--- mac OS Sierra 10.12.6
--- CRAN R 3.4.3
---clang & gfortran
$ clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gfortran --version
GNU Fortran (GCC) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I will update once I have access to and try this on several other mac boxes with different specs..
Thank you to everyone for the help.
@Ralf
Post by Ralf Stubner
I had not installed the necessary C library, so unsurprisingly the compilation step already failed. What I find interesting is that in my case "-std=gnu++11“ and "-I../inst/include/" are present in the command line options for clang++. These are also missing from what you quoted and are also a consequence of src/Makevars. It almost looks as if this file got lost on your macOS box …
Interesting....I'm not sure what to make of this of course, but it would be interesting if it was only happening on this macbook. Perhaps OS version or brew could be to blame? I'm not sure what else would be "special" about this macbook....
On my side that would be
• macOS high Sierra
• CRAN R 3.4.4
• clang and gfortran as recommended by CRAN
• brew is installed but I do not see how it enters the picture
Greetings
Ralf
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Evan Biederstedt
2018-05-01 14:24:49 UTC
Permalink
@Keith
Post by Keith O'Hara
Unless I'm mistaken, neither are required to install binary packages. Can
curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.
500.0.tar.gz
Post by Keith O'Hara
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
This looks successful

```

$ R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz


* installing to library
‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’

* installing *source* package ‘RcppArmadillo’ ...

** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked

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 clang++ accepts -g... yes

checking how to run the C++ preprocessor... clang++ -E

checking whether we are using the GNU C++ compiler... (cached) yes

checking whether clang++ accepts -g... (cached) yes

checking whether g++ version is sufficient... almost

configure: WARNING: Compiler self-identifies as being compliant with GNUC
extensions but is not g++.

checking for macOS... found

checking for macOS Apple compiler... found

configure: WARNING: OpenMP unavailable and turned off.

checking LAPACK_LIBS... R-supplied partial LAPACK found

configure: WARNING: Some complex-valued LAPACK functions may not be
available

configure: creating ./config.status

config.status: creating inst/include/RcppArmadilloConfigGenerated.h

config.status: creating src/Makevars

** libs

clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c
RcppArmadillo.cpp -o RcppArmadillo.o

clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c
RcppExports.cpp -o RcppExports.o

clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c fastLm.cpp
-o fastLm.o

clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names
-undefined dynamic_lookup -single_module -multiply_defined suppress
-L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o
RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o
-L/Library/Frameworks/R.framework/Resources/lib -lRlapack
-L/Library/Frameworks/R.framework/Resources/lib -lRblas
-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0
-L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
-Wl,CoreFoundation

ld: warning: directory not found for option
'-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'

ld: warning: directory not found for option '-L/usr/local/gfortran/lib'

installing to
/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RcppArmadillo/libs

** R

** inst

** preparing package for lazy loading

** help

*** installing help indices

** building package indices

** installing vignettes

** testing if installed package can be loaded

* DONE (RcppArmadillo)

```
Post by Keith O'Hara
Check your build directory for any .Rprofile or .Renviron files, and also
check ~/.R/Makevars for errors.

I'm using the command line. I do not seem to have anything in `$ cat
~/.R/Makevars` or `$cat ~/.Rprofile`. Perhaps this is the problem?
Post by Keith O'Hara
If you can list the required libraries for bamdb, I'm happy to try a
build on my end. (I'm lazy to go through the CMake list :-))

There are four dependencies:

htslib/1.5 or higher: https://github.com/samtools/htslib

LMDB key-value store: https://github.com/LMDB/lmdb

Concurreny-Ck: https://github.com/concurrencykit/ck

zlib: Standard compression library https://github.com/madler/zlib
(probably already installed)

Mac OS:
```
brew install lmdb
brew install concurrencykit
brew install zlib // mac OS already provides this software
brew install htslib // I *think* this is the latest htslib, but I would
double-check
```

Linux (for the record):
```
yum install libhts-dev ## dev branch of latest htslib
yum install liblmdb-dev ## LMDB dev
yum install libck-dev ## Concurrency-ck
yum install libz-dev ## zlib compresssion
```
Post by Keith O'Hara
Unless I'm mistaken, neither are required to install binary packages. Can
curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.
500.0.tar.gz
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
If that goes through without a hitch then it's probably a package issue.
Are you using RStudio? Check your build directory for any .Rprofile or
.Renviron files, and also check ~/.R/Makevars for errors.
If you can list the required libraries for bamdb, I'm happy to try a build
on my end. (I'm lazy to go through the CMake list :-))
Keith
Post by Evan Biederstedt
I would add, I think clang and gfortran are working correctly, as these
are required for `install.packages('RcppArmadillo')` to install properly.
Post by Evan Biederstedt
On Tue, May 1, 2018 at 3:06 AM, Evan Biederstedt <
Maybe my Mac OS needs updating...possibly something with XCode, but it's
not clear how...
Post by Evan Biederstedt
--- mac OS Sierra 10.12.6
--- CRAN R 3.4.3
---clang & gfortran
$ clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gfortran --version
GNU Fortran (GCC) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
Post by Evan Biederstedt
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
Post by Evan Biederstedt
I will update once I have access to and try this on several other mac
boxes with different specs..
Post by Evan Biederstedt
Thank you to everyone for the help.
On Tue, May 1, 2018 at 1:44 AM, Ralf Stubner <
Am 30.04.2018 um 23:42 schrieb Evan Biederstedt <
Post by Evan Biederstedt
@Ralf
Post by Ralf Stubner
I had not installed the necessary C library, so unsurprisingly the
compilation step already failed. What I find interesting is that in my case
"-std=gnu++11“ and "-I../inst/include/" are present in the command line
options for clang++. These are also missing from what you quoted and are
also a consequence of src/Makevars. It almost looks as if this file got
lost on your macOS box 

Post by Evan Biederstedt
Post by Evan Biederstedt
Interesting....I'm not sure what to make of this of course, but it
would be interesting if it was only happening on this macbook. Perhaps OS
version or brew could be to blame? I'm not sure what else would be
"special" about this macbook....
Post by Evan Biederstedt
On my side that would be
• macOS high Sierra
• CRAN R 3.4.4
• clang and gfortran as recommended by CRAN
• brew is installed but I do not see how it enters the picture
Greetings
Ralf
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Dirk Eddelbuettel
2018-05-01 15:31:47 UTC
Permalink
Evan,

Could you possibly construct a smaller, self-contained example exhibiting the
same problem? That may be more efficient than requiring volunteer helpers to
install four other libraries.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Keith O'Hara
2018-05-01 15:42:36 UTC
Permalink
Worked for me, after I modified the install name of libbamdb (from a runtime path to the installation directory, /usr/local/lib/libbamdb.dylib).

* installing to library ‘/Users/<blah blah>/R-devel/lib/R/library’
* installing *source* package ‘bambi’ ...
** libs
clang++-mp-6.0 -std=gnu++11 -I"/Users/<blah blah>/R-devel/lib/R/include" -DNDEBUG -I../inst/include/ -I/usr/local/include/bamdb -I/opt/local/include -I"/Users/<blah blah>/R-devel/lib/R/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -march=native -g -O3 -ffp-contract=fast -c RcppExports.cpp -o RcppExports.o
clang++-mp-6.0 -std=gnu++11 -I"/Users/<blah blah>/R-devel/lib/R/include" -DNDEBUG -I../inst/include/ -I/usr/local/include/bamdb -I/opt/local/include -I"/Users/<blah blah>/R-devel/lib/R/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -march=native -g -O3 -ffp-contract=fast -c bambi.cpp -o bambi.o
clang++-mp-6.0 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Users/<blah blah>/R-devel/lib/R/lib -L/usr/local/lib -o bambi.so RcppExports.o bambi.o -lbamdb -L/opt/local/lib -llmdb -lhts -L/Users/<blah blah>/R-devel/lib/R/lib -lR -Wl,-framework -Wl,CoreFoundation
installing to /Users/<blah blah>/R-devel/lib/R/library/bambi/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (bambi)

Try building from a new, clean directory.

Keith
Post by Evan Biederstedt
@Keith
Post by Keith O'Hara
curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.500.0.tar.gz
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
This looks successful
```
$ R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
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 clang++ accepts -g... yes
checking how to run the C++ preprocessor... clang++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ accepts -g... (cached) yes
checking whether g++ version is sufficient... almost
configure: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++.
checking for macOS... found
checking for macOS Apple compiler... found
configure: WARNING: OpenMP unavailable and turned off.
checking LAPACK_LIBS... R-supplied partial LAPACK found
configure: WARNING: Some complex-valued LAPACK functions may not be available
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c RcppArmadillo.cpp -o RcppArmadillo.o
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c fastLm.cpp -o fastLm.o
clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/RcppArmadillo/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RcppArmadillo)
```
Post by Keith O'Hara
Check your build directory for any .Rprofile or .Renviron files, and also check ~/.R/Makevars for errors.
I'm using the command line. I do not seem to have anything in `$ cat ~/.R/Makevars` or `$cat ~/.Rprofile`. Perhaps this is the problem?
Post by Keith O'Hara
If you can list the required libraries for bamdb, I'm happy to try a build on my end. (I'm lazy to go through the CMake list :-))
htslib/1.5 or higher: https://github.com/samtools/htslib
LMDB key-value store: https://github.com/LMDB/lmdb
Concurreny-Ck: https://github.com/concurrencykit/ck
zlib: Standard compression library https://github.com/madler/zlib (probably already installed)
```
brew install lmdb
brew install concurrencykit
brew install zlib // mac OS already provides this software
brew install htslib // I *think* this is the latest htslib, but I would double-check
```
```
yum install libhts-dev ## dev branch of latest htslib
yum install liblmdb-dev ## LMDB dev
yum install libck-dev ## Concurrency-ck
yum install libz-dev ## zlib compresssion
```
curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.500.0.tar.gz
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
If that goes through without a hitch then it's probably a package issue. Are you using RStudio? Check your build directory for any .Rprofile or .Renviron files, and also check ~/.R/Makevars for errors.
If you can list the required libraries for bamdb, I'm happy to try a build on my end. (I'm lazy to go through the CMake list :-))
Keith
Post by Keith O'Hara
I would add, I think clang and gfortran are working correctly, as these are required for `install.packages('RcppArmadillo')` to install properly.
Maybe my Mac OS needs updating...possibly something with XCode, but it's not clear how...
--- mac OS Sierra 10.12.6
--- CRAN R 3.4.3
---clang & gfortran
$ clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gfortran --version
GNU Fortran (GCC) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I will update once I have access to and try this on several other mac boxes with different specs..
Thank you to everyone for the help.
@Ralf
Post by Ralf Stubner
I had not installed the necessary C library, so unsurprisingly the compilation step already failed. What I find interesting is that in my case "-std=gnu++11“ and "-I../inst/include/" are present in the command line options for clang++. These are also missing from what you quoted and are also a consequence of src/Makevars. It almost looks as if this file got lost on your macOS box …
Interesting....I'm not sure what to make of this of course, but it would be interesting if it was only happening on this macbook. Perhaps OS version or brew could be to blame? I'm not sure what else would be "special" about this macbook....
On my side that would be
• macOS high Sierra
• CRAN R 3.4.4
• clang and gfortran as recommended by CRAN
• brew is installed but I do not see how it enters the picture
Greetings
Ralf
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Evan Biederstedt
2018-05-01 16:04:22 UTC
Permalink
@Dirk
Post by Dirk Eddelbuettel
Could you possibly construct a smaller, self-contained example exhibiting
the
same problem? That may be more efficient than requiring volunteer helpers to
install four other libraries.

Apologies, this is on the to-do list.

@Keith

Thanks for trying this out. This is interesting.
Post by Dirk Eddelbuettel
Worked for me, after I modified the install name of libbamdb (from a
runtime path to the installation directory, /usr/local/lib/libbamdb.dylib).

I want to be sure I understand---Could you clarify this? Which changes did
you make?

That is created with `sudo make install`, i.e. from above

```

$ sudo make install

Password:

[ 50%] Built target bamdb

[100%] Built target libbamdb

Install the project...

-- Install configuration: ""

-- Installing: /usr/local/bin/bamdb

-- Up-to-date: /usr/local/include/bamdb

-- Up-to-date: /usr/local/include/bamdb/bam_api.h

-- Up-to-date: /usr/local/include/bamdb/bam_lmdb.h

-- Up-to-date: /usr/local/include/bamdb/bamdb.h

-- Installing: /usr/local/lib/libbamdb.dylib
```
Post by Dirk Eddelbuettel
Worked for me, after I modified the install name of libbamdb (from a
runtime path to the installation directory, /usr/local/lib/libbamdb.dylib)
.
* installing to library ‘/Users/<blah blah>/R-devel/lib/R/library’
* installing *source* package ‘bambi’ ...
** libs
clang++-mp-6.0 -std=gnu++11 -I"/Users/<blah blah>/R-devel/lib/R/include"
-DNDEBUG -I../inst/include/ -I/usr/local/include/bamdb -I/opt/local/include
-I"/Users/<blah blah>/R-devel/lib/R/library/Rcpp/include"
-I/usr/local/include -fPIC -Wall -march=native -g -O3 -ffp-contract=fast
-c RcppExports.cpp -o RcppExports.o
clang++-mp-6.0 -std=gnu++11 -I"/Users/<blah blah>/R-devel/lib/R/include"
-DNDEBUG -I../inst/include/ -I/usr/local/include/bamdb -I/opt/local/include
-I"/Users/<blah blah>/R-devel/lib/R/library/Rcpp/include"
-I/usr/local/include -fPIC -Wall -march=native -g -O3 -ffp-contract=fast
-c bambi.cpp -o bambi.o
clang++-mp-6.0 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names
-undefined dynamic_lookup -single_module -multiply_defined suppress
-L/Users/<blah blah>/R-devel/lib/R/lib -L/usr/local/lib -o bambi.so
RcppExports.o bambi.o -lbamdb -L/opt/local/lib -llmdb -lhts -L/Users/<blah
blah>/R-devel/lib/R/lib -lR -Wl,-framework -Wl,CoreFoundation
installing to /Users/<blah blah>/R-devel/lib/R/library/bambi/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (bambi)
Try building from a new, clean directory.
Keith
On May 1, 2018, at 10:24 AM, Evan Biederstedt <
@Keith
Post by Keith O'Hara
Unless I'm mistaken, neither are required to install binary packages.
curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.
500.0.tar.gz
Post by Keith O'Hara
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
This looks successful
```
$ R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/
Resources/library’
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
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 clang++ accepts -g... yes
checking how to run the C++ preprocessor... clang++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ accepts -g... (cached) yes
checking whether g++ version is sufficient... almost
configure: WARNING: Compiler self-identifies as being compliant with
GNUC extensions but is not g++.
checking for macOS... found
checking for macOS Apple compiler... found
configure: WARNING: OpenMP unavailable and turned off.
checking LAPACK_LIBS... R-supplied partial LAPACK found
configure: WARNING: Some complex-valued LAPACK functions may not be
available
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/
Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include
-fPIC -Wall -g -O2 -c RcppArmadillo.cpp -o RcppArmadillo.o
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/
Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include
-fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/
Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include
-fPIC -Wall -g -O2 -c fastLm.cpp -o fastLm.o
clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names
-undefined dynamic_lookup -single_module -multiply_defined suppress
-L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o
RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o
-L/Library/Frameworks/R.framework/Resources/lib -lRlapack
-L/Library/Frameworks/R.framework/Resources/lib -lRblas
-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0
-L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/..
-framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/
gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
installing to /Library/Frameworks/R.framework/Versions/3.4/
Resources/library/RcppArmadillo/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RcppArmadillo)
```
Post by Keith O'Hara
Check your build directory for any .Rprofile or .Renviron files, and
also check ~/.R/Makevars for errors.
I'm using the command line. I do not seem to have anything in `$ cat
~/.R/Makevars` or `$cat ~/.Rprofile`. Perhaps this is the problem?
Post by Keith O'Hara
If you can list the required libraries for bamdb, I'm happy to try a
build on my end. (I'm lazy to go through the CMake list :-))
htslib/1.5 or higher: https://github.com/samtools/htslib
LMDB key-value store: https://github.com/LMDB/lmdb
Concurreny-Ck: https://github.com/concurrencykit/ck
zlib: Standard compression library https://github.com/madler/zlib
(probably already installed)
```
brew install lmdb
brew install concurrencykit
brew install zlib // mac OS already provides this software
brew install htslib // I *think* this is the latest htslib, but I would
double-check
```
```
yum install libhts-dev ## dev branch of latest htslib
yum install liblmdb-dev ## LMDB dev
yum install libck-dev ## Concurrency-ck
yum install libz-dev ## zlib compresssion
```
Unless I'm mistaken, neither are required to install binary packages.
curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.
500.0.tar.gz
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
If that goes through without a hitch then it's probably a package issue.
Are you using RStudio? Check your build directory for any .Rprofile or
.Renviron files, and also check ~/.R/Makevars for errors.
If you can list the required libraries for bamdb, I'm happy to try a
build on my end. (I'm lazy to go through the CMake list :-))
Keith
Post by Keith O'Hara
On May 1, 2018, at 3:07 AM, Evan Biederstedt <
I would add, I think clang and gfortran are working correctly, as
these are required for `install.packages('RcppArmadillo')` to install
properly.
Post by Keith O'Hara
On Tue, May 1, 2018 at 3:06 AM, Evan Biederstedt <
Maybe my Mac OS needs updating...possibly something with XCode, but
it's not clear how...
Post by Keith O'Hara
--- mac OS Sierra 10.12.6
--- CRAN R 3.4.3
---clang & gfortran
$ clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gfortran --version
GNU Fortran (GCC) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There
is NO
Post by Keith O'Hara
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
Post by Keith O'Hara
I will update once I have access to and try this on several other mac
boxes with different specs..
Post by Keith O'Hara
Thank you to everyone for the help.
On Tue, May 1, 2018 at 1:44 AM, Ralf Stubner <
Am 30.04.2018 um 23:42 schrieb Evan Biederstedt <
Post by Evan Biederstedt
@Ralf
Post by Ralf Stubner
I had not installed the necessary C library, so unsurprisingly the
compilation step already failed. What I find interesting is that in my case
"-std=gnu++11“ and "-I../inst/include/" are present in the command line
options for clang++. These are also missing from what you quoted and are
also a consequence of src/Makevars. It almost looks as if this file got
lost on your macOS box 

Post by Keith O'Hara
Post by Evan Biederstedt
Interesting....I'm not sure what to make of this of course, but it
would be interesting if it was only happening on this macbook. Perhaps OS
version or brew could be to blame? I'm not sure what else would be
"special" about this macbook....
Post by Keith O'Hara
On my side that would be
• macOS high Sierra
• CRAN R 3.4.4
• clang and gfortran as recommended by CRAN
• brew is installed but I do not see how it enters the picture
Greetings
Ralf
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/
listinfo/rcpp-devel
Keith O'Hara
2018-05-01 17:26:32 UTC
Permalink
From my experience, R (on macOS) doesn't play well with libraries that have install names containing runtime search paths. By changing the install name, I mean changing the '@rpath' part here:

$ otool -L /usr/local/lib/libbamdb.dylib

/usr/local/lib/libbamdb.dylib:
@rpath/libbamdb.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/local/lib/libck.0.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/local/lib/libhts.2.dylib (compatibility version 2.0.0, current version 1.8.0)
/opt/local/lib/liblmdb.dylib (compatibility version 0.0.0, current version 0.0.0)
...

using:

$ sudo install_name_tool -id /usr/local/lib/libbamdb.dylib /usr/local/lib/libbamdb.dylib
$ otool -L /usr/local/lib/libbamdb.dylib
/usr/local/lib/libbamdb.dylib:
/usr/local/lib/libbamdb.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/local/lib/libck.0.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/local/lib/libhts.2.dylib (compatibility version 2.0.0, current version 1.8.0)
/opt/local/lib/liblmdb.dylib (compatibility version 0.0.0, current version 0.0.0)
...

Then build the R package (R CMD INSTALL …). Otherwise you could hit an 'image not found' error. (But, to be clear, this error is not related to Rcpp.)

Keith
Post by Dirk Eddelbuettel
@Dirk
Post by Dirk Eddelbuettel
Could you possibly construct a smaller, self-contained example exhibiting the
same problem? That may be more efficient than requiring volunteer helpers to
install four other libraries.
Apologies, this is on the to-do list.
@Keith
Thanks for trying this out. This is interesting.
Post by Dirk Eddelbuettel
Worked for me, after I modified the install name of libbamdb (from a runtime path to the installation directory, /usr/local/lib/libbamdb.dylib).
I want to be sure I understand---Could you clarify this? Which changes did you make?
That is created with `sudo make install`, i.e. from above
```
$ sudo make install
[ 50%] Built target bamdb
[100%] Built target libbamdb
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/bin/bamdb
-- Up-to-date: /usr/local/include/bamdb
-- Up-to-date: /usr/local/include/bamdb/bam_api.h
-- Up-to-date: /usr/local/include/bamdb/bam_lmdb.h
-- Up-to-date: /usr/local/include/bamdb/bamdb.h
-- Installing: /usr/local/lib/libbamdb.dylib
```
Worked for me, after I modified the install name of libbamdb (from a runtime path to the installation directory, /usr/local/lib/libbamdb.dylib).
* installing to library ‘/Users/<blah blah>/R-devel/lib/R/library’
* installing *source* package ‘bambi’ ...
** libs
clang++-mp-6.0 -std=gnu++11 -I"/Users/<blah blah>/R-devel/lib/R/include" -DNDEBUG -I../inst/include/ -I/usr/local/include/bamdb -I/opt/local/include -I"/Users/<blah blah>/R-devel/lib/R/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -march=native -g -O3 -ffp-contract=fast -c RcppExports.cpp -o RcppExports.o
clang++-mp-6.0 -std=gnu++11 -I"/Users/<blah blah>/R-devel/lib/R/include" -DNDEBUG -I../inst/include/ -I/usr/local/include/bamdb -I/opt/local/include -I"/Users/<blah blah>/R-devel/lib/R/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -march=native -g -O3 -ffp-contract=fast -c bambi.cpp -o bambi.o
clang++-mp-6.0 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Users/<blah blah>/R-devel/lib/R/lib -L/usr/local/lib -o bambi.so RcppExports.o bambi.o -lbamdb -L/opt/local/lib -llmdb -lhts -L/Users/<blah blah>/R-devel/lib/R/lib -lR -Wl,-framework -Wl,CoreFoundation
installing to /Users/<blah blah>/R-devel/lib/R/library/bambi/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (bambi)
Try building from a new, clean directory.
Keith
Post by Dirk Eddelbuettel
@Keith
Post by Keith O'Hara
curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.500.0.tar.gz
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
This looks successful
```
$ R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
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 clang++ accepts -g... yes
checking how to run the C++ preprocessor... clang++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ accepts -g... (cached) yes
checking whether g++ version is sufficient... almost
configure: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++.
checking for macOS... found
checking for macOS Apple compiler... found
configure: WARNING: OpenMP unavailable and turned off.
checking LAPACK_LIBS... R-supplied partial LAPACK found
configure: WARNING: Some complex-valued LAPACK functions may not be available
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c RcppArmadillo.cpp -o RcppArmadillo.o
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c fastLm.cpp -o fastLm.o
clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/RcppArmadillo/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RcppArmadillo)
```
Post by Keith O'Hara
Check your build directory for any .Rprofile or .Renviron files, and also check ~/.R/Makevars for errors.
I'm using the command line. I do not seem to have anything in `$ cat ~/.R/Makevars` or `$cat ~/.Rprofile`. Perhaps this is the problem?
Post by Keith O'Hara
If you can list the required libraries for bamdb, I'm happy to try a build on my end. (I'm lazy to go through the CMake list :-))
htslib/1.5 or higher: https://github.com/samtools/htslib
LMDB key-value store: https://github.com/LMDB/lmdb
Concurreny-Ck: https://github.com/concurrencykit/ck
zlib: Standard compression library https://github.com/madler/zlib (probably already installed)
```
brew install lmdb
brew install concurrencykit
brew install zlib // mac OS already provides this software
brew install htslib // I *think* this is the latest htslib, but I would double-check
```
```
yum install libhts-dev ## dev branch of latest htslib
yum install liblmdb-dev ## LMDB dev
yum install libck-dev ## Concurrency-ck
yum install libz-dev ## zlib compresssion
```
curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.500.0.tar.gz
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
If that goes through without a hitch then it's probably a package issue. Are you using RStudio? Check your build directory for any .Rprofile or .Renviron files, and also check ~/.R/Makevars for errors.
If you can list the required libraries for bamdb, I'm happy to try a build on my end. (I'm lazy to go through the CMake list :-))
Keith
Post by Keith O'Hara
I would add, I think clang and gfortran are working correctly, as these are required for `install.packages('RcppArmadillo')` to install properly.
Maybe my Mac OS needs updating...possibly something with XCode, but it's not clear how...
--- mac OS Sierra 10.12.6
--- CRAN R 3.4.3
---clang & gfortran
$ clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gfortran --version
GNU Fortran (GCC) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I will update once I have access to and try this on several other mac boxes with different specs..
Thank you to everyone for the help.
@Ralf
Post by Ralf Stubner
I had not installed the necessary C library, so unsurprisingly the compilation step already failed. What I find interesting is that in my case "-std=gnu++11“ and "-I../inst/include/" are present in the command line options for clang++. These are also missing from what you quoted and are also a consequence of src/Makevars. It almost looks as if this file got lost on your macOS box …
Interesting....I'm not sure what to make of this of course, but it would be interesting if it was only happening on this macbook. Perhaps OS version or brew could be to blame? I'm not sure what else would be "special" about this macbook....
On my side that would be
• macOS high Sierra
• CRAN R 3.4.4
• clang and gfortran as recommended by CRAN
• brew is installed but I do not see how it enters the picture
Greetings
Ralf
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Evan Biederstedt
2018-05-03 20:19:20 UTC
Permalink
Hi @Keith

Thanks for the help and apologies for the delay. You're correct---when I
change the install name it does work, i.e. use `sudo install_name_tool -id
/usr/local/lib/libbamdb.dylib /usr/local/lib/libbamdb.dylib`

Thanks for this! I hadn't known about `@rpath` in Mac OS, and in retrospect
I should have done more work looking into the properties of these shared
libraries. And thanks for the list, as this wasn't an Rcpp issue at all.

This segues to the next step, which is Rcpp-related: compiling this
together into one R package. Combine bamdb + bambi into one R package.

@list

Working with Linux first, is it common to compile a C library (i.e. bamdb)
within /src, and then use extern? My understanding is that I will have to
change the R package's Makevars to compile the C library first, and then
link to this.

If there are any examples on github which you would be able to recommend,
that might be best. Then I can close this thread :)

Thank you for the help!
Post by Keith O'Hara
From my experience, R (on macOS) doesn't play well with libraries that
have install names containing runtime search paths. By changing the install
$ otool -L /usr/local/lib/libbamdb.dylib
@rpath/libbamdb.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/local/lib/libck.0.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/local/lib/libhts.2.dylib (compatibility version 2.0.0, current version 1.8.0)
/opt/local/lib/liblmdb.dylib (compatibility version 0.0.0, current version 0.0.0)
...
$ sudo install_name_tool -id /usr/local/lib/libbamdb.dylib
/usr/local/lib/libbamdb.dylib
$ otool -L /usr/local/lib/libbamdb.dylib
/usr/local/lib/libbamdb.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/local/lib/libck.0.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/local/lib/libhts.2.dylib (compatibility version 2.0.0, current version 1.8.0)
/opt/local/lib/liblmdb.dylib (compatibility version 0.0.0, current version 0.0.0)
...
Then build the R package (R CMD INSTALL 
). Otherwise you could hit an
'image not found' error. (But, to be clear, this error is not related to
Rcpp.)
Keith
On May 1, 2018, at 12:04 PM, Evan Biederstedt <
@Dirk
Post by Dirk Eddelbuettel
Could you possibly construct a smaller, self-contained example
exhibiting the
same problem? That may be more efficient than requiring volunteer
helpers to
install four other libraries.
Apologies, this is on the to-do list.
@Keith
Thanks for trying this out. This is interesting.
Post by Dirk Eddelbuettel
Worked for me, after I modified the install name of libbamdb (from a
runtime path to the installation directory, /usr/local/lib/libbamdb.dylib)
.
I want to be sure I understand---Could you clarify this? Which changes
did you make?
That is created with `sudo make install`, i.e. from above
```
$ sudo make install
[ 50%] Built target bamdb
[100%] Built target libbamdb
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/bin/bamdb
-- Up-to-date: /usr/local/include/bamdb
-- Up-to-date: /usr/local/include/bamdb/bam_api.h
-- Up-to-date: /usr/local/include/bamdb/bam_lmdb.h
-- Up-to-date: /usr/local/include/bamdb/bamdb.h
-- Installing: /usr/local/lib/libbamdb.dylib
```
Worked for me, after I modified the install name of libbamdb (from a
runtime path to the installation directory, /usr/local/lib/libbamdb.dylib)
.
* installing to library ‘/Users/<blah blah>/R-devel/lib/R/library’
* installing *source* package ‘bambi’ ...
** libs
clang++-mp-6.0 -std=gnu++11 -I"/Users/<blah blah>/R-devel/lib/R/include"
-DNDEBUG -I../inst/include/ -I/usr/local/include/bamdb -I/opt/local/include
-I"/Users/<blah blah>/R-devel/lib/R/library/Rcpp/include"
-I/usr/local/include -fPIC -Wall -march=native -g -O3 -ffp-contract=fast
-c RcppExports.cpp -o RcppExports.o
clang++-mp-6.0 -std=gnu++11 -I"/Users/<blah blah>/R-devel/lib/R/include"
-DNDEBUG -I../inst/include/ -I/usr/local/include/bamdb -I/opt/local/include
-I"/Users/<blah blah>/R-devel/lib/R/library/Rcpp/include"
-I/usr/local/include -fPIC -Wall -march=native -g -O3 -ffp-contract=fast
-c bambi.cpp -o bambi.o
clang++-mp-6.0 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names
-undefined dynamic_lookup -single_module -multiply_defined suppress
-L/Users/<blah blah>/R-devel/lib/R/lib -L/usr/local/lib -o bambi.so
RcppExports.o bambi.o -lbamdb -L/opt/local/lib -llmdb -lhts -L/Users/<blah
blah>/R-devel/lib/R/lib -lR -Wl,-framework -Wl,CoreFoundation
installing to /Users/<blah blah>/R-devel/lib/R/library/bambi/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (bambi)
Try building from a new, clean directory.
Keith
Post by Dirk Eddelbuettel
On May 1, 2018, at 10:24 AM, Evan Biederstedt <
@Keith
Post by Keith O'Hara
Unless I'm mistaken, neither are required to install binary
curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.500
.0.tar.gz
Post by Dirk Eddelbuettel
Post by Keith O'Hara
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
This looks successful
```
$ R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
* installing to library ‘/Library/Frameworks/R.framewo
rk/Versions/3.4/Resources/library’
Post by Dirk Eddelbuettel
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
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 clang++ accepts -g... yes
checking how to run the C++ preprocessor... clang++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ accepts -g... (cached) yes
checking whether g++ version is sufficient... almost
configure: WARNING: Compiler self-identifies as being compliant with
GNUC extensions but is not g++.
Post by Dirk Eddelbuettel
checking for macOS... found
checking for macOS Apple compiler... found
configure: WARNING: OpenMP unavailable and turned off.
checking LAPACK_LIBS... R-supplied partial LAPACK found
configure: WARNING: Some complex-valued LAPACK functions may not be
available
Post by Dirk Eddelbuettel
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c
RcppArmadillo.cpp -o RcppArmadillo.o
Post by Dirk Eddelbuettel
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c
RcppExports.cpp -o RcppExports.o
Post by Dirk Eddelbuettel
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
-DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
-I/usr/local/include -I../inst/include -fPIC -Wall -g -O2 -c fastLm.cpp
-o fastLm.o
Post by Dirk Eddelbuettel
clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names
-undefined dynamic_lookup -single_module -multiply_defined suppress
-L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o
RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o
-L/Library/Frameworks/R.framework/Resources/lib -lRlapack
-L/Library/Frameworks/R.framework/Resources/lib -lRblas
-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0
-L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
-Wl,CoreFoundation
Post by Dirk Eddelbuettel
ld: warning: directory not found for option
'-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
Post by Dirk Eddelbuettel
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/
library/RcppArmadillo/libs
Post by Dirk Eddelbuettel
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RcppArmadillo)
```
Post by Keith O'Hara
Check your build directory for any .Rprofile or .Renviron files, and
also check ~/.R/Makevars for errors.
Post by Dirk Eddelbuettel
I'm using the command line. I do not seem to have anything in `$ cat
~/.R/Makevars` or `$cat ~/.Rprofile`. Perhaps this is the problem?
Post by Dirk Eddelbuettel
Post by Keith O'Hara
If you can list the required libraries for bamdb, I'm happy to try a
build on my end. (I'm lazy to go through the CMake list :-))
Post by Dirk Eddelbuettel
htslib/1.5 or higher: https://github.com/samtools/htslib
LMDB key-value store: https://github.com/LMDB/lmdb
Concurreny-Ck: https://github.com/concurrencykit/ck
zlib: Standard compression library https://github.com/madler/zlib
(probably already installed)
Post by Dirk Eddelbuettel
```
brew install lmdb
brew install concurrencykit
brew install zlib // mac OS already provides this software
brew install htslib // I *think* this is the latest htslib, but I
would double-check
Post by Dirk Eddelbuettel
```
```
yum install libhts-dev ## dev branch of latest htslib
yum install liblmdb-dev ## LMDB dev
yum install libck-dev ## Concurrency-ck
yum install libz-dev ## zlib compresssion
```
Unless I'm mistaken, neither are required to install binary packages.
curl -O https://cran.r-project.org/src/contrib/RcppArmadillo_0.8.500
.0.tar.gz
Post by Dirk Eddelbuettel
R CMD INSTALL RcppArmadillo_0.8.500.0.tar.gz
If that goes through without a hitch then it's probably a package
issue. Are you using RStudio? Check your build directory for any .Rprofile
or .Renviron files, and also check ~/.R/Makevars for errors.
Post by Dirk Eddelbuettel
If you can list the required libraries for bamdb, I'm happy to try a
build on my end. (I'm lazy to go through the CMake list :-))
Post by Dirk Eddelbuettel
Keith
Post by Keith O'Hara
On May 1, 2018, at 3:07 AM, Evan Biederstedt <
I would add, I think clang and gfortran are working correctly, as
these are required for `install.packages('RcppArmadillo')` to install
properly.
Post by Dirk Eddelbuettel
Post by Keith O'Hara
On Tue, May 1, 2018 at 3:06 AM, Evan Biederstedt <
Maybe my Mac OS needs updating...possibly something with XCode, but
it's not clear how...
Post by Dirk Eddelbuettel
Post by Keith O'Hara
--- mac OS Sierra 10.12.6
--- CRAN R 3.4.3
---clang & gfortran
$ clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gfortran --version
GNU Fortran (GCC) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There
is NO
Post by Dirk Eddelbuettel
Post by Keith O'Hara
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
Post by Dirk Eddelbuettel
Post by Keith O'Hara
I will update once I have access to and try this on several other
mac boxes with different specs..
Post by Dirk Eddelbuettel
Post by Keith O'Hara
Thank you to everyone for the help.
On Tue, May 1, 2018 at 1:44 AM, Ralf Stubner <
Am 30.04.2018 um 23:42 schrieb Evan Biederstedt <
Post by Evan Biederstedt
@Ralf
Post by Ralf Stubner
I had not installed the necessary C library, so unsurprisingly
the compilation step already failed. What I find interesting is that in my
case "-std=gnu++11“ and "-I../inst/include/" are present in the command
line options for clang++. These are also missing from what you quoted and
are also a consequence of src/Makevars. It almost looks as if this file got
lost on your macOS box 

Post by Dirk Eddelbuettel
Post by Keith O'Hara
Post by Evan Biederstedt
Interesting....I'm not sure what to make of this of course, but it
would be interesting if it was only happening on this macbook. Perhaps OS
version or brew could be to blame? I'm not sure what else would be
"special" about this macbook....
Post by Dirk Eddelbuettel
Post by Keith O'Hara
On my side that would be
• macOS high Sierra
• CRAN R 3.4.4
• clang and gfortran as recommended by CRAN
• brew is installed but I do not see how it enters the picture
Greetings
Ralf
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo
/rcpp-devel
Dirk Eddelbuettel
2018-05-03 22:38:17 UTC
Permalink
On 3 May 2018 at 16:19, Evan Biederstedt wrote:
| Working with Linux first, is it common to compile a C library (i.e. bamdb)
| within /src, and then use extern? My understanding is that I will have to
| change the R package's Makevars to compile the C library first, and then
| link to this.
|
| If there are any examples on github which you would be able to recommend,
| that might be best. Then I can close this thread :)

You have the hardest possibe deployment option here it requires temporary
root to make a library a system library -- and R CMD ... does not have that.

You need to change your plan. Using external libraries is hard. There are no
freebies.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Evan Biederstedt
2018-05-03 23:08:22 UTC
Permalink
Hi Dirk

I appreciate the help.
Post by Dirk Eddelbuettel
You have the hardest possibe deployment option here it requires temporary
root to make a library a system library -- and R CMD ... does not have that.

I think I was able to sidestep this.

After installing bamdb without 'sudo make install'/root privileges, I was
able to hack the Makevars to install bambi on Linux

```
CXX_STD = CXX11

PKG_CPPFLAGS += -I../inst/include/
PKG_LIBS= -lhts -L/nfs/sw/htslib/htslib-1.7 -llmdb -L/usr/local/lib -lbamdb
-L/blah/blah/bamdb/build
```

Given the R package structure, I was thinking it would be possible to link
to the C library (not installed with 'sudo make install') via the `-L`
flag, maybe `-L/something/src/bamdb/build`

If this would work, the unsolved problem would be using the Makevars to
accomplish the `cmake .. && make` step....

Does this sound crazy?
Post by Dirk Eddelbuettel
| Working with Linux first, is it common to compile a C library (i.e. bamdb)
| within /src, and then use extern? My understanding is that I will have to
| change the R package's Makevars to compile the C library first, and then
| link to this.
|
| If there are any examples on github which you would be able to recommend,
| that might be best. Then I can close this thread :)
You have the hardest possibe deployment option here it requires temporary
root to make a library a system library -- and R CMD ... does not have that.
You need to change your plan. Using external libraries is hard. There are no
freebies.
Dirk
--
Dirk Eddelbuettel
2018-05-04 00:46:08 UTC
Permalink
On 3 May 2018 at 19:08, Evan Biederstedt wrote:
| Given the R package structure, I was thinking it would be possible to link
| to the C library (not installed with 'sudo make install') via the `-L`
| flag, maybe `-L/something/src/bamdb/build`

This would work if and only if ldconfig exported the (shared) library.

But as we said you do not have (root) access to ldconfig (apart from on your
own machine) so maybe you need to look into static libraries.

And that, just like the rest of thread, has nothing to do with Rcpp per se so
maybe we should not extend this thread any further here.

Doing sys.admin-ing in a portable way across different OSs is not a solved
problem, even though R solved building packages portably for us.

Sorry. I wish I had better news for you.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Continue reading on narkive:
Loading...