Open BoxWong opened 1 month ago
Hi Xin,
Thank you for reaching out, and I'm sorry to hear you're having trouble installing BPCells. The error message you're encountering indicates that the compiler is unable to compile a program using C++17's std::filesystem features. This usually happens if the compiler doesn't fully support C++17 or if R isn't properly configured to use the correct compiler. Additionally, there shouldn't be a need to add in -std=c++17 (but adding it in shouldn't break compilation) within your flags as this is done within our configure file. Let's try to do some additional work to diagnose why compilation isn't working for you.
Sys.setenv(BPCELLS_DEBUG_INSTALL=TRUE)
before installing to get additional debugging information printed out.pkgbuild::check_build_tools(debug = TRUE)
to see if your cpp build tools are being properly recognized within R.<path_to_compiler> --version
and ensure that the version works with C++17. GCC versions above 7 should have all the features required to pass checks within the BPCells configure file.<path_to_g++> r/tools/cxx17_filesystem.cc -std=c++17 -o r/tools/cxx17_filesystem; r/tools/cxx17_filesystem
from the root directory of BPCells, and ensure that "test/path.txt"
is being printed out. That is what is being checked to produce the error message you are seeing.Best,
Immanuel
Hello Immanuel,
Thank you for your previous response in this open issue. Unfortunately, when trying to install BPCells after Sys.setenv(BPCELLS_DEBUG_INSTALL=TRUE)
, I get the following error:
Installing package into ‘/c4/home/juanmoriano/.R’ (as ‘lib’ is unspecified)
- installing source package ‘BPCells’ ... ** using staged installation
- '[' -z '' ']'
- ENABLE_INSTALL_COUNTING=yes
- '[' yes == yes ']'
- curl --silent https://plausible.benparks.net/flask-plausible/bpcells-configure
- echo 'Recording install count metrics' Recording install count metrics ++ /software/c4/cbi/software/_rocky8/R-4.4.2-gcc13/lib64/R/bin/R CMD config CC
- CC=gcc ++ /software/c4/cbi/software/_rocky8/R-4.4.2-gcc13/lib64/R/bin/R CMD config CXX
- CXX='g++ -std=gnu++17'
- ENV_CFLAGS=-I/software/c4/cbi/software/gdal-3.6.4/include
- ENV_LDFLAGS=-L/software/c4/cbi/software/gdal-3.6.4/lib64 ++ /software/c4/cbi/software/_rocky8/R-4.4.2-gcc13/lib64/R/bin/R CMD config CFLAGS
- CFLAGS='-g -O2 -I/software/c4/cbi/software/gdal-3.6.4/include' ++ /software/c4/cbi/software/_rocky8/R-4.4.2-gcc13/lib64/R/bin/R CMD config CXXFLAGS
- CXXFLAGS='-g -O2 -I/software/c4/cbi/software/gdal-3.6.4/include' ++ /software/c4/cbi/software/_rocky8/R-4.4.2-gcc13/lib64/R/bin/R CMD config LDFLAGS
- LDFLAGS='-L/usr/local/lib64 -L/software/c4/cbi/software/gdal-3.6.4/lib64'
- echo 'Testing hdf5 by compiling example program...' Testing hdf5 by compiling example program...
- HDF5_CFLAGS=
- HDF5_LIBS=-lhdf5
- HDF5_OK=
- gcc tools/h5write.c -g -O2 -I/software/c4/cbi/software/gdal-3.6.4/include -L/usr/local/lib64 -L/software/c4/cbi/software/gdal-3.6.4/lib64 -lhdf5 -o tools/h5write
- HDF5_OK=yes
- '[' -z yes ']'
- '[' -z yes ']'
- '[' -z yes ']'
- '[' -z yes ']'
- echo 'Found working hdf5' Found working hdf5
- echo 'HDF5_CFLAGS='\'''\''' HDF5_CFLAGS=''
- echo 'HDF5_LIBS='\''-lhdf5'\''' HDF5_LIBS='-lhdf5'
- CXX17_OK=
- CXX_FS_FLAG=
- printf '\nTesting C++17 filesystem feature support...'
Testing C++17 filesystem feature support...+ g++ -std=gnu++17 tools/cxx17_filesystem.cc -g -O2 -I/software/c4/cbi/software/gdal-3.6.4/include -L/usr/local/lib64 -L/software/c4/cbi/software/gdal-3.6.4/lib64 -std=c++17 -o tools/cxx17_filesystem
- CXX17_OK=yes
- '[' -z yes ']'
- '[' -z yes ']'
- '[' -z yes ']'
- printf '\nTesting availability of highway SIMD library...'
Testing availability of highway SIMD library...+ HWY_OK=
- HWY_CFLAGS=-Ibpcells-cpp
- HWY_LIBS=-lhwy
- g++ -std=gnu++17 tools/hwy-test.cpp -g -O2 -I/software/c4/cbi/software/gdal-3.6.4/include -L/usr/local/lib64 -L/software/c4/cbi/software/gdal-3.6.4/lib64 tools/hwy-test.cpp:1:10: fatal error: hwy/highway.h: No such file or directory 1 | #include <hwy/highway.h> | ^
~~~~~~ compilation terminated.
(...)
Error: package or namespace load failed for ‘BPCells’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/c4/home/juanmoriano/.R/00LOCK-BPCells/00new/BPCells/libs/BPCells.so': /c4/home/juanmoriano/.R/00LOCK-BPCells/00new/BPCells/libs/BPCells.so: undefined symbol: H5Treclaim Error: loading failed Execution halted ERROR: loading failed
- removing ‘/c4/home/juanmoriano/.R/BPCells’ Warning message: In i.p(...) : installation of package ‘/scratch/juanmoriano/RtmpIVheTC/file1f85c8105e77ef/BPCells_0.2.0.tar.gz’ had non-zero exit status
pkgbuild::check_build_tools(debug = TRUE)
works well but /usr/bin/g++ r/tools/cxx17_filesystem.cc -std=c++17 -o r/tools/cxx17_filesystem; r/tools/cxx17_filesystem
gives
/tmp/ccdEwXaT.o: In function `std::filesystem::cxx11::path::path<char [14], std::filesystem::cxx11::path>(char const (&) [14], std::filesystem::__cxx11::path::format)':
cxx17_filesystem.cc:(.text._ZNSt10filesystem7__cxx114pathC2IA14_cS1_EERKT_NS1_6formatE[_ZNSt10filesystem7cxx114pathC5IA14_cS1_EERKT_NS1_6formatE]+0x5e):
undefined reference to
std::filesystem::cxx11::path::_M_split_cmpts()'collect2:` error: ld returned 1 exit status
-bash:` r/tools/cxx17_filesystem: No such file or directory
Could you provide further help on this issue?
Hi Juan, Thanks for trying out BPCells!
I went ahead and tried to install BPCells on Rocky 8.10, to validate some of your issues. On a base installation, I wasn't able to reproduce the failure, so let's try to dig a little bit deeper at what is causing your issue.
Just to clarify a few things:
/usr/bin/g++ r/tools/cxx17_filesystem.cc -std=c++17 -o r/tools/cxx17_filesystem; r/tools/cxx17_filesystem
is not expected to pass when using gcc8, as it requires a flag that we set within the configure
file: "-lc++fs". To reproduce with gcc8, please try
/usr/bin/g++ r/tools/cxx17_filesystem.cc -std=c++17 -lstdc++fs -o r/tools/cxx17_filesystem; r/tools/cxx17_filesystem
.
Second, a full rebuild of BPCells expects for the highway library to not be found, if you aren't installing locally. This is fine, and we build it as an additional step.
I think what is the culprit is the following:
Error: package or namespace load failed for ‘BPCells’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/c4/home/juanmoriano/.R/00LOCK-BPCells/00new/BPCells/libs/BPCells.so':
/c4/home/juanmoriano/.R/00LOCK-BPCells/00new/BPCells/libs/BPCells.so: undefined symbol: H5Treclaim
This indicates that you are able to compile, but it is failing on the step of loading it in. This is likely because there are two versions of hdf5 that are being used (similar to #44). This can occur from a variety of reasons, like non-standard hdf5 path installation, and using a conda environment to install (#84 and #124).
If it is because of a conda install, I would recommend doing conda install conda-forge::hdf5
.
If not, I would try to do some diagnostics pointed out in #44. Try running r/tools/h5write
and ldd r/tools/h5write | fgrep hdf5
I would compare the results to pkg-config hdf5 --cflags
and see what the differences are.
Once you have an idea where the libraries are for hdf5 that your R is using, you can shove them in as environment variables in $CFLAGS
and $LDFLAGS
similar to how #84 did it.
Feel free to ping again if you're having difficulty for this!
Immanuel
Glad to hear it!
Hi bnprks,
I'm trying to install BPCells on a linux server, but I got the following error:
Testing C++17 filesystem feature support...
Unable to compile program with C++17 std::filesystem. Please install a newer compiler version and set CC and CXX in ~/.R/Makevars ERROR: configuration failed for package ‘BPCells’
I looked it up and found it may be due to the version of C++ compiler, then I created the ~/.R/Makevars file and changed the setting of compiler in the file: CC = /data/wangxin/software/miniconda3/bin/gcc CXX = /data/wangxin/software/miniconda3/bin/g++ CXXFLAGS += -std=c++17 CXX11FLAGS += -std=c++17
I restarted R and tried installing again, but I still got the same error. Would you have any solution for this?
Thanks, Xin