rohan-shah / mpMap2

New version of mpMap
12 stars 5 forks source link

findRcpp.cmake not found #1

Closed Weiming-Hu closed 7 years ago

Weiming-Hu commented 7 years ago

When I'm doing an out-of-tree build under mpMap2/build, I got the following error message:

CMake Error at /usr/local/Cellar/cmake/3.8.2/share/cmake/Modules/FindBoost.cmake:1842 (message):
  Unable to find the requested Boost libraries.

  Unable to find the Boost header files.  Please set BOOST_ROOT to the root
  directory containing Boost or BOOST_INCLUDEDIR to the directory containing
  Boost's headers.
Call Stack (most recent call first):
  CMakeLists.txt:18 (find_package)

CMake Error at CMakeLists.txt:24 (find_package):
  By not providing "FindRcpp.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Rcpp", but
  CMake did not find one.

  Could not find a package configuration file provided by "Rcpp" with any of
  the following names:

    RcppConfig.cmake
    rcpp-config.cmake

  Add the installation prefix of "Rcpp" to CMAKE_PREFIX_PATH or set
  "Rcpp_DIR" to a directory containing one of the above files.  If "Rcpp"
  provides a separate development package or SDK, be sure it has been
  installed.

I have used find_package(Boost ...) function in my own CMakeLists.txt, and there is no error. Wierd....

And I don't find FindRcpp.cmake in your project.

Thank you.

rohan-shah commented 7 years ago

You need to download rohan-shah/Rcpp and build that using CMake. As part of building that package, a file RcppConfig.cmake is generated. You can then refer to that when building mpMap2 using -DRcpp_DIR=\<RcppBinaryDir>.

I have added these instructions to Readme.md .

Regarding boost, is it possible you don't have the graph or regex components built? Or that your installed version is older than 1.50.0? It's not required in any case, you can disable it with -DUSE_BOOST=OFF. I have updated the default state of this option to OFF.

Weiming-Hu commented 7 years ago

Thank you. I'll check my Boost components. As for FindRcpp.cmake, I've installed in R using command install.packages(). If I install your version, will it be conflict with mine? Why don't you put the FindRcpp file in this repo and speechify the MODULE_PATH?

Weiming-Hu commented 7 years ago

OK. I got it working through manually R CMD install and R CMD build, but not cmake and make. It first complains about

Warning message:
package ‘roxygen_devtest’ is not available (for R version 3.4.0)

After searching, I made some changes in you CMakeLists.txt per suggestions here. On CMakeLists.txt line 61, I changed roxygen2::roxygenise() to devtools::document(), and it seems like passing. But again, it fails later complaining:

* installing *source* package ‘mpMap2’ ...
ERROR: a 'NAMESPACE' file is required

But you definitely have the NAMESPACE file under in the project. Any ideas?

Another random ask is that, since R CMD build system works and CMake doesn't, does this mean that as a R pakcage developer, we should not bypass the R CMD build system?

Thank you!

Update

The problem is with the current version of roxygen. So don't change the line 61. Just use an older version of the package.

devtools::install_version(package = 'roxygen2',version = '5.0.1', repos = c(CRAN = "https://cran.rstudio.com"))
rohan-shah commented 7 years ago

There appears to be a bug in the newest roxygen2 which was not present previously. You'll have to wait for a fix from haddley.

The custom Rcpp you downloaded compiles to a static library. It is not an R package, so there is no conflict.

I don't know what that NAMESPACE error is about. Did you follow the instructions under "Package Compilation" of Readme.md, using an out-of-source build?

Yes, the CMake build system does work, but you must be doing something I have not tested. And no, you should not use this system unless you have a good reason to. If you want it fixed, you need to send me a minimal reproducible example.

Weiming-Hu commented 7 years ago

OK. I have compiled Rcpp at ~/tmp/Rcpp, and I have a libRcpp.a and RcppConfig.cmake under ~/tmp/Rcpp/build directory. For mpMap2, I'm doing an out-of-tree build in~/tmp/mpMap2/build directory. I have run cmake -DRcpp_DIR=$HOME/tmp/Rcpp/build .. and make && make install. Everything is working until the last step of linking the library.

Undefined symbols for architecture x86_64:
  "_ATTRIB", referenced from:
      Rcpp::AttributeProxyPolicy<Rcpp::RObject_Impl<Rcpp::PreserveStorage> >::hasAttribute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in checkHets.cpp.o
  "_CAR", referenced from:
      get_last_call() in alleleDataErrors.cpp.o
      get_last_call() in combineGenotypes.cpp.o
      get_last_call() in estimateRF.cpp.o
      get_last_call() in fourParentPedigreeRandomFunnels.cpp.o
      get_last_call() in generateGenotypes.cpp.o
      get_last_call() in intercrossingAndSelfingGenerations.cpp.o
      get_last_call() in matrixChunks.cpp.o
      ...
  "_CDDR", referenced from:
      Rcpp::Rcpp_eval(SEXPREC*, SEXPREC*) in alleleDataErrors.cpp.o
      Rcpp::Rcpp_eval(SEXPREC*, SEXPREC*) in checkHets.cpp.o
      Rcpp::Rcpp_eval(SEXPREC*, SEXPREC*) in combineGenotypes.cpp.o
      Rcpp::Rcpp_eval(SEXPREC*, SEXPREC*) in estimateRF.cpp.o
      Rcpp::Rcpp_topLevelExec(SEXPREC*, SEXPREC*) in estimateRF.cpp.o
      Rcpp::Rcpp_eval(SEXPREC*, SEXPREC*) in estimateRFCheckFunnels.cpp.o
      Rcpp::Rcpp_eval(SEXPREC*, SEXPREC*) in estimateRFSpecificDesign.cpp.o
      ...

"_VECTOR_ELT", referenced from:
      Rcpp::internal::generic_proxy<19>::get() const in alleleDataErrors.cpp.o
      Rcpp::internal::generic_proxy<19>::get() const in checkHets.cpp.o
      Rcpp::internal::generic_proxy<19>::get() const in combineGenotypes.cpp.o
      Rcpp::internal::generic_proxy<19>::get() const in estimateRF.cpp.o
      Rcpp::internal::generic_proxy<19>::get() const in estimateRFCheckFunnels.cpp.o
      Rcpp::internal::generic_proxy<19>::get() const in estimateRFSpecificDesign.cpp.o
      Rcpp::internal::generic_proxy<19>::get() const in intercrossingAndSelfingGenerations.cpp.o
      ...
  "_unif_rand", referenced from:
      createGamete(Rcpp::Vector<14, Rcpp::PreserveStorage>&, Rcpp::Vector<13, Rcpp::PreserveStorage>&, int*) in generateGenotypes.cpp.o
      Rcpp::stats::UnifGenerator::operator()() const in generateGenotypes.cpp.o
      arsa(arsaArgs&) in arsa.cpp.o
      getPairForSwap(long, long&, long&) in arsa.cpp.o
      getPairForMove(long, long&, long&, int) in arsa.cpp.o
      arsaRaw(arsaRawArgs&) in arsaRaw.cpp.o
      getPairForSwap(long, long&, long&) in arsaRaw.cpp.o
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/mpMap2.dylib] Error 1
make[1]: *** [src/CMakeFiles/mpMap2.dir/all] Error 2
make: *** [all] Error 2

It looks like it is complaining about Rcpp linking. Any ideas? Thank you

rohan-shah commented 7 years ago

Yeah, that's failure to link to libR.so. Can I please get a copy of the link command?

Please check that libR.so is present in one of the directories passed with -L. Also, did you compile R yourself? I have never tested with a version of R compiled without --enable-R-shlib.

Weiming-Hu commented 7 years ago

I installed R using brew, and below is the configuration info:

users$ brew info R
homebrew/science/r: stable 3.4.0 (bottled), HEAD
Software environment for statistical computing
https://www.r-project.org/
/usr/local/Cellar/r/3.4.0_1 (2,247 files, 59MB) *
  Poured from bottle on 2017-05-05 at 15:26:14
From: https://github.com/Homebrew/homebrew-science/blob/master/r.rb
==> Dependencies
Build: pkg-config ✔, texinfo ✘
Required: readline ✔, gettext ✔, libtiff ✔, pcre ✔, jpeg ✔, libpng ✔, xz ✔, cairo ✔
Optional: openblas ✘, pango ✘, valgrind ✘
==> Requirements
Required: fortran ✔
Optional: x11 ✔
==> Options
--with-librmath-only
    Only build standalone libRmath library
--with-openblas
    Build with openblas support
--with-pango
    Build with pango support
--with-valgrind
    Build with valgrind support
--with-x11
    Build with x11 support
--without-accelerate
    Build without the Accelerate framework (use Rblas)
--without-tcltk
    Build without Tcl/Tk
--without-test
    Skip build-time tests (not recommended)
--HEAD
    Install HEAD version
==> Caveats
To enable rJava support, run the following command:
  R CMD javareconf JAVA_CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
If you've installed a version of Java other than the default, you might need to instead use:
  R CMD javareconf JAVA_CPPFLAGS="-I/System/Library/Frameworks/JavaVM.framework/Headers -I/Library/Java/JavaVirtualMachines/jdk<version>.jdk/"
(where <version> can be found by running `java -version`, `/usr/libexec/java_home`, or `locate jni.h`), or:
  R CMD javareconf JAVA_CPPFLAGS="-I/System/Library/Frameworks/JavaVM.framework/Headers -I$(/usr/libexec/java_home | grep -o '.*jdk')"

There is no --enable-R-shlib. What does this do? Thank you.

rohan-shah commented 7 years ago

Oh, you're on a mac. I don't own one, so it's not well tested there. I'll borrow one next time I get a chance, and fix the link commands.

Weiming-Hu commented 7 years ago

Sure. Thanks.

Weiming-Hu commented 7 years ago

Hi. Is it true that when install the pakage using R CMD system, Boost library is not used?

rohan-shah commented 7 years ago

Yes, that's correct. Getting boost to work with Makefiles is just too unpleasant.

I haven't forgotten about testing on a mac.

Weiming-Hu commented 7 years ago

Thank you. I encountered the same awkwardness when trying to include Boost library into my R package. At last, I decided to transfer entirely to autotools and configure, which has more support from Rcpp....

I'm looking at the linking problem right now. I have tried to link to the Rcpp compiled using your code, and the Rcpp installed by R. But the problem is still there.

rohan-shah commented 7 years ago

Compilation may be fixed on osX. Tested on a whole one system.

The roxygen2 bug remains, but not much I can do about that immediately.

rohan-shah commented 7 years ago

I'm going to go ahead and close this soon, unless there's anything else.....