girke-lab / ChemmineOB

OpenBabel wrapper package for R
Other
10 stars 5 forks source link

ChemmineOB not compiling from Bioconductor in Mac 13.5.2 #35

Open deb-m opened 8 months ago

deb-m commented 8 months ago

When I try to install ChemmineOB from Bioconductor using this command

if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager") 
BiocManager::install("ChemmineOB", force = TRUE)"

I am getting the following output. I know it did not find openbabel, though the problem seems to be related to compilation issue with respect to using "std::binary_function" instead of "std::__binary_function" in the ChemmineOB.cpp source code.

getOption("repos")' replaces Bioconductor standard repositories, see 'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
    CRAN: https://cran.rstudio.com/
Bioconductor version 3.18 (BiocManager 1.30.22), R 4.3.3 (2024-02-29)
Installing package(s) 'ChemmineOB'
trying URL 'https://bioconductor.org/packages/3.18/bioc/src/contrib/ChemmineOB_1.40.0.tar.gz'
Content type 'application/x-gzip' length 1366043 bytes (1.3 MB)
==================================================
downloaded 1.3 MB

* installing *source* package ‘ChemmineOB’ ...
** using staged installation
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for OPENBABEL... no
checking for OPENBABEL... no
checking for gcc... clang
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 for clang option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -E
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘Apple clang version 15.0.0 (clang-1500.0.40.1)’
using SDK: ‘MacOSX14.0.sdk’
clang++ -std=gnu++17 -I"/usr/local/Cellar/r/4.3.3/lib/R/include" -DNDEBUG -I/usr/include/openbabel3  -I/usr/include/eigen3  -DUSE_BOOST -DHAVE_EIGEN  -I/usr/local/include/eigen3 -I/usr/local/include/openbabel3    -I'/usr/local/lib/R/4.3/site-library/BH/include' -I'/usr/local/lib/R/4.3/site-library/Rcpp/include' -I'/usr/local/lib/R/4.3/site-library/zlibbioc/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include    -fPIC  -g -O2  -c ChemmineOB.cpp -o ChemmineOB.o
In file included from ChemmineOB.cpp:1587:
In file included from /usr/local/include/openbabel3/openbabel/obconversion.h:37:
In file included from /usr/local/include/openbabel3/openbabel/format.h:22:
/usr/local/include/openbabel3/openbabel/plugin.h:41:42: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
struct OBERROR CharPtrLess : public std::binary_function<const char*,const char*, bool>
                                    ~~~~~^~~~~~~~~~~~~~~
                                         __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13728:45: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
SWIGEXPORT SEXP R_swig_new_dummy ( ) { std::binary_function< char const *,char const *,bool > *result = 0 ;
                                       ~~~~~^~~~~~~~~~~~~~~
                                            __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13730:18: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
  result = (std::binary_function< char const *,char const *,bool > *)new std::binary_function< char const *,char const *,bool >();
            ~~~~~^~~~~~~~~~~~~~~
                 __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13730:79: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
  result = (std::binary_function< char const *,char const *,bool > *)new std::binary_function< char const *,char const *,bool >();
                                                                         ~~~~~^~~~~~~~~~~~~~~
                                                                              __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13734:8: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
  std::binary_function< char const *,char const *,bool > *arg1 = (std::binary_function< char const *,char const *,bool > *) 0 ;
  ~~~~~^~~~~~~~~~~~~~~
       __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13734:72: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
  std::binary_function< char const *,char const *,bool > *arg1 = (std::binary_function< char const *,char const *,bool > *) 0 ;
                                                                  ~~~~~^~~~~~~~~~~~~~~
                                                                       __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13739:34: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
   arg1 = reinterpret_cast< std::binary_function< char const *,char const *,bool > * >(argp1); delete arg1; r_ans = R_NilValue;
                            ~~~~~^~~~~~~~~~~~~~~
                                 __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:39656:27: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
    return (void *)((std::binary_function< char const *,char const *,bool > *)  ((OpenBabel::CharPtrLess *) x));
                     ~~~~~^~~~~~~~~~~~~~~
                          __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
8 errors generated.
make: *** [ChemmineOB.o] Error 1
ERROR: compilation failed for package ‘ChemmineOB’
* removing ‘/usr/local/lib/R/4.3/site-library/ChemmineOB’

The downloaded source packages are in
    ‘/private/var/folders/zq/177206l93831d3zm33nvmc4w0000gn/T/Rtmp1Qy5L3/downloaded_packages’
Warning message:
In install.packages(...) :
  installation of package ‘ChemmineOB’ had non-zero exit status

Any help regarding this issue will be much appreciated. Thanks Deb

khoran commented 8 months ago

Sorry you're having trouble. The underscores are likely a result of name mangling rather than actual function names. The code compiles fine for me with the same function names. Can you tell me what version of OpenBabel you have installed? Also, it would be important for the configure script to find openbabel, as it will then set various options differently which could affect the compilation. I'm not too familiar with macs or how to get it to detect the OpenBabel package, unfortunately, nor do I have a mac handy to test things on.

Ideally, the line that currently says:

checking for OPENBABEL... no

should say "yes".

Aariq commented 6 months ago

I'm also having issues building ChemmineOB from source on macOS both on my macbook and on a GitHub runner.

Output from BiocManager::install ``` > BiocManager::install("ChemmineOB", force = TRUE, type = "source") 'getOption("repos")' replaces Bioconductor standard repositories, see 'help("repositories", package = "BiocManager")' for details. Replacement repositories: CRAN: https://cloud.r-project.org Bioconductor version 3.18 (BiocManager 1.30.22), R 4.3.2 (2023-10-31) Installing package(s) 'ChemmineOB' trying URL 'https://bioconductor.org/packages/3.18/bioc/src/contrib/ChemmineOB_1.40.0.tar.gz' Content type 'application/x-gzip' length 1366043 bytes (1.3 MB) ================================================== downloaded 1.3 MB * installing *source* package ‘ChemmineOB’ ... ** using staged installation checking for pkg-config... /usr/local/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for OPENBABEL... no checking for OPENBABEL... no checking for gcc... clang -arch x86_64 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 -arch x86_64 accepts -g... yes checking for clang -arch x86_64 option to accept ISO C89... none needed checking how to run the C preprocessor... clang -arch x86_64 -E configure: creating ./config.status config.status: creating src/Makevars ** libs using C++ compiler: ‘Apple clang version 15.0.0 (clang-1500.3.9.4)’ using SDK: ‘MacOSX14.4.sdk’ clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/include" -DNDEBUG -I/usr/include/openbabel3 -I/usr/include/eigen3 -DUSE_BOOST -DHAVE_EIGEN -I/usr/local/include/eigen3 -I/usr/local/include/openbabel3 -I'/Users/ericscott/Library/R/x86_64/4.3/library/BH/include' -I'/Users/ericscott/Library/R/x86_64/4.3/library/Rcpp/include' -I'/Users/ericscott/Library/R/x86_64/4.3/library/zlibbioc/include' -I/opt/R/x86_64/include -fPIC -falign-functions=64 -Wall -g -O2 -c ChemmineOB.cpp -o ChemmineOB.o In file included from ChemmineOB.cpp:1576: /usr/local/include/openbabel3/openbabel/griddata.h:74:12: warning: 'OpenBabel::OBGridData::GetValue' hides overloaded virtual function [-Woverloaded-virtual] double GetValue(int i, int j, int k) const; ^ /usr/local/include/openbabel3/openbabel/base.h:228:32: note: hidden overloaded virtual function 'OpenBabel::OBGenericData::GetValue' declared here: different number of parameters (0 vs 3) virtual const std::string &GetValue() const ^ In file included from ChemmineOB.cpp:1576: /usr/local/include/openbabel3/openbabel/griddata.h:76:12: warning: 'OpenBabel::OBGridData::GetValue' hides overloaded virtual function [-Woverloaded-virtual] double GetValue (vector3 pos) const; ^ /usr/local/include/openbabel3/openbabel/base.h:228:32: note: hidden overloaded virtual function 'OpenBabel::OBGenericData::GetValue' declared here: different number of parameters (0 vs 1) virtual const std::string &GetValue() const ^ In file included from ChemmineOB.cpp:1582: /usr/local/include/openbabel3/openbabel/reaction.h:99:15: warning: 'OpenBabel::OBReaction::GetTitle' hides overloaded virtual function [-Woverloaded-virtual] std::string GetTitle() const { return _title; } ^ /usr/local/include/openbabel3/openbabel/base.h:286:28: note: hidden overloaded virtual function 'OpenBabel::OBBase::GetTitle' declared here: different number of parameters (1 vs 0) virtual const char *GetTitle(bool UNUSED(replaceNewlines) = true) const { return "";} ^ In file included from ChemmineOB.cpp:1582: /usr/local/include/openbabel3/openbabel/reaction.h:101:8: warning: 'OpenBabel::OBReaction::SetTitle' hides overloaded virtual function [-Woverloaded-virtual] void SetTitle(const std::string& title) { _title=title; } ^ /usr/local/include/openbabel3/openbabel/base.h:287:21: note: hidden overloaded virtual function 'OpenBabel::OBBase::SetTitle' declared here: type mismatch at 1st parameter ('const char *' vs 'const std::string &' (aka 'const basic_string &')) virtual void SetTitle(const char *) {} ^ In file included from ChemmineOB.cpp:1587: In file included from /usr/local/include/openbabel3/openbabel/obconversion.h:37: In file included from /usr/local/include/openbabel3/openbabel/format.h:22: /usr/local/include/openbabel3/openbabel/plugin.h:41:42: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'? struct OBERROR CharPtrLess : public std::binary_function ~~~~~^~~~~~~~~~~~~~~ __binary_function /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; ^ ChemmineOB.cpp:4160:7: warning: unused variable 'ecode' [-Wunused-variable] int ecode = 0; arg1 = (std::ios_base::event) swigarg_arg1; arg2 = (std::ios_base *) &swigarg_arg2; arg3 = (int) swigarg_arg3; ^ ChemmineOB.cpp:13728:45: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'? SWIGEXPORT SEXP R_swig_new_dummy ( ) { std::binary_function< char const *,char const *,bool > *result = 0 ; ~~~~~^~~~~~~~~~~~~~~ __binary_function /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; ^ ChemmineOB.cpp:13730:18: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'? result = (std::binary_function< char const *,char const *,bool > *)new std::binary_function< char const *,char const *,bool >(); ~~~~~^~~~~~~~~~~~~~~ __binary_function /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; ^ ChemmineOB.cpp:13730:79: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'? result = (std::binary_function< char const *,char const *,bool > *)new std::binary_function< char const *,char const *,bool >(); ~~~~~^~~~~~~~~~~~~~~ __binary_function /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; ^ ChemmineOB.cpp:13734:8: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'? std::binary_function< char const *,char const *,bool > *arg1 = (std::binary_function< char const *,char const *,bool > *) 0 ; ~~~~~^~~~~~~~~~~~~~~ __binary_function /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; ^ ChemmineOB.cpp:13734:72: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'? std::binary_function< char const *,char const *,bool > *arg1 = (std::binary_function< char const *,char const *,bool > *) 0 ; ~~~~~^~~~~~~~~~~~~~~ __binary_function /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; ^ ChemmineOB.cpp:13739:34: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'? arg1 = reinterpret_cast< std::binary_function< char const *,char const *,bool > * >(argp1); delete arg1; r_ans = R_NilValue; ~~~~~^~~~~~~~~~~~~~~ __binary_function /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; ^ ChemmineOB.cpp:39656:27: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'? return (void *)((std::binary_function< char const *,char const *,bool > *) ((OpenBabel::CharPtrLess *) x)); ~~~~~^~~~~~~~~~~~~~~ __binary_function /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; ^ 5 warnings and 8 errors generated. make: *** [ChemmineOB.o] Error 1 ERROR: compilation failed for package ‘ChemmineOB’ * removing ‘/Users/ericscott/Library/R/x86_64/4.3/library/ChemmineOB’ * restoring previous ‘/Users/ericscott/Library/R/x86_64/4.3/library/ChemmineOB’ ```

I have OpenBabel 3.1.0 installed. which obabel returns /usr/local/bin/obabel

barracuda156 commented 6 months ago

This is related to Clang, apparently, since it builds normally with GCC.

UPD. Wait, maybe I know the reason. Could be a local issue, though not sure, since the earlier version built fine.

barracuda156 commented 6 months ago

@khoran

Ideally, the line that currently says:

checking for OPENBABEL... no

should say "yes".

Configure is pretty broken and searches some rather random paths.

barracuda156 commented 6 months ago

By the way, while GCC compiles it, it still complains:

--->  Configuring R-ChemmineOB
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-ChemmineOB/R-ChemmineOB/work/ChemmineOB" && /opt/local/bin/R CMD build . --no-manual --no-build-vignettes --keep-empty-dirs 
* checking for file ‘./DESCRIPTION’ ... OK
* preparing ‘ChemmineOB’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* running ‘cleanup’
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘ChemmineOB_1.42.0.tar.gz’

--->  Building R-ChemmineOB
xinstall: mkdir /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-ChemmineOB/R-ChemmineOB/work/build
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-ChemmineOB/R-ChemmineOB/work/ChemmineOB" && /opt/local/bin/R CMD INSTALL . --library=/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-ChemmineOB/R-ChemmineOB/work/build --install-tests 
* installing *source* package ‘ChemmineOB’ ...
** using staged installation
checking for pkg-config... /opt/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for OPENBABEL... no
checking for OPENBABEL... no
checking for gcc... /opt/local/bin/gcc-mp-13
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 /opt/local/bin/gcc-mp-13 accepts -g... yes
checking for /opt/local/bin/gcc-mp-13 option to accept ISO C89... none needed
checking how to run the C preprocessor... /opt/local/bin/gcc-mp-13 -E
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘g++-mp-13 (MacPorts gcc13 13.2.0_4+stdlib_flag) 13.2.0’
Warning in system2("xcrun", "--show-sdk-path", TRUE, TRUE) :
  running command ''xcrun' --show-sdk-path 2>&1' had status 64
using SDK: ‘NA’‘NA’‘NA’‘NA’‘NA’‘NA’
/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -D_GLIBCXX_USE_CXX11_ABI=0 -DUSE_BOOST -DHAVE_EIGEN -I/opt/local/include/openbabel3 -I/opt/local/include/eigen3 -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/zlibbioc/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc   -c ChemmineOB.cpp -o ChemmineOB.o
In file included from /opt/local/include/openbabel3/openbabel/format.h:22,
                 from /opt/local/include/openbabel3/openbabel/obconversion.h:37,
                 from ChemmineOB.cpp:1587:
/opt/local/include/openbabel3/openbabel/plugin.h:41:42: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
   41 | struct OBERROR CharPtrLess : public std::binary_function<const char*,const char*, bool>
      |                                          ^~~~~~~~~~~~~~~
In file included from /opt/local/include/gcc13/c++/string:49,
                 from /opt/local/include/gcc13/c++/stdexcept:39,
                 from ChemmineOB.cpp:1559:
/opt/local/include/gcc13/c++/bits/stl_function.h:131:12: note: declared here
  131 |     struct binary_function
      |            ^~~~~~~~~~~~~~~
ChemmineOB.cpp: In function 'SEXPREC* R_swig_new_dummy()':
ChemmineOB.cpp:13728:45: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
13728 | SWIGEXPORT SEXP R_swig_new_dummy ( ) { std::binary_function< char const *,char const *,bool > *result = 0 ;
      |                                             ^~~~~~~~~~~~~~~
/opt/local/include/gcc13/c++/bits/stl_function.h:131:12: note: declared here
  131 |     struct binary_function
      |            ^~~~~~~~~~~~~~~
ChemmineOB.cpp:13730:18: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
13730 |   result = (std::binary_function< char const *,char const *,bool > *)new std::binary_function< char const *,char const *,bool >();
      |                  ^~~~~~~~~~~~~~~
/opt/local/include/gcc13/c++/bits/stl_function.h:131:12: note: declared here
  131 |     struct binary_function
      |            ^~~~~~~~~~~~~~~
ChemmineOB.cpp:13730:79: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
13730 |   result = (std::binary_function< char const *,char const *,bool > *)new std::binary_function< char const *,char const *,bool >();
      |                                                                               ^~~~~~~~~~~~~~~
/opt/local/include/gcc13/c++/bits/stl_function.h:131:12: note: declared here
  131 |     struct binary_function
      |            ^~~~~~~~~~~~~~~
ChemmineOB.cpp: In function 'SEXPREC* R_swig_delete_dummy(SEXP)':
ChemmineOB.cpp:13734:8: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
13734 |   std::binary_function< char const *,char const *,bool > *arg1 = (std::binary_function< char const *,char const *,bool > *) 0 ;
      |        ^~~~~~~~~~~~~~~
/opt/local/include/gcc13/c++/bits/stl_function.h:131:12: note: declared here
  131 |     struct binary_function
      |            ^~~~~~~~~~~~~~~
ChemmineOB.cpp:13734:72: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
13734 |   std::binary_function< char const *,char const *,bool > *arg1 = (std::binary_function< char const *,char const *,bool > *) 0 ;
      |                                                                        ^~~~~~~~~~~~~~~
/opt/local/include/gcc13/c++/bits/stl_function.h:131:12: note: declared here
  131 |     struct binary_function
      |            ^~~~~~~~~~~~~~~
. . .
barracuda156 commented 6 months ago

It can likely be fixed by adding -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION when building against libc++ (no need to add it with libstdc++).

khoran commented 6 months ago

It can likely be fixed by adding -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION when building against libc++ (no need to add it with libstdc++).

If someone can confirm if that suggestion helps I'd be happy to add it. I can't test it myself as I don't have a mac build machine handy.

barracuda156 commented 6 months ago

@khoran As you can see, we have it fixed for every macOS version: https://ports.macports.org/port/R-ChemmineOB/details

Flags are chosen depending on stdlib being used in this chunk: https://github.com/macports/macports-ports/blob/5cf0c73dd96a13ab007b4290a7c5cc895aca1b5a/R/R-ChemmineOB/Portfile#L29-L40

Aariq commented 3 months ago

@khoran As you can see, we have it fixed for every macOS version: https://ports.macports.org/port/R-ChemmineOB/details

ChemmineOB v1.42.0 still fails to build on GitHub actions macOS runner

barracuda156 commented 3 months ago

@khoran As you can see, we have it fixed for every macOS version: https://ports.macports.org/port/R-ChemmineOB/details

ChemmineOB v1.42.0 still fails to build on GitHub actions macOS runner

As far as I can see, everything builds on buildbots: https://ports.macports.org/port/R-ChemmineOB/details That should imply CI gonna pass as well, unless something got broken from dependencies.

Aariq commented 3 months ago

On my mac (macOS Sonoma, intel macbook) I get a build error with three different install methods in addition to the above failing GitHub action.

  1. installing from Bioconductor with pak::pkg_install("bioc::ChemmineOB?source")
  2. installing from GitHub with pak::pkg_install("girke-lab/ChemmineOB")
  3. installing from Bioconductor with BiocManager::install("ChemmineOB", type = "source", version = "3.19")

Here's the output of the last method:

> BiocManager::install("ChemmineOB", type = "source", version = "3.19")
'getOption("repos")' replaces Bioconductor standard repositories, see 'help("repositories", package = "BiocManager")' for
details.
Replacement repositories:
    CRAN: https://cloud.r-project.org
Bioconductor version 3.19 (BiocManager 1.30.23), R 4.4.0 (2024-04-24)
Installing package(s) 'ChemmineOB'
trying URL 'https://bioconductor.org/packages/3.19/bioc/src/contrib/ChemmineOB_1.42.0.tar.gz'
Content type 'application/x-gzip' length 1367470 bytes (1.3 MB)
==================================================
downloaded 1.3 MB

* installing *source* package ‘ChemmineOB’ ...
** using staged installation
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for OPENBABEL... no
checking for OPENBABEL... no
checking for gcc... clang -arch x86_64
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 -arch x86_64 accepts -g... yes
checking for clang -arch x86_64 option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -arch x86_64 -E
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘Apple clang version 15.0.0 (clang-1500.3.9.4)’
using SDK: ‘MacOSX14.4.sdk’
clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/include" -DNDEBUG -I/usr/include/openbabel3  -I/usr/include/eigen3  -DUSE_BOOST -DHAVE_EIGEN  -I/usr/local/include/eigen3 -I/usr/local/include/openbabel3    -I'/Users/ericscott/Library/R/x86_64/4.4/library/BH/include' -I'/Users/ericscott/Library/R/x86_64/4.4/library/Rcpp/include' -I'/Users/ericscott/Library/R/x86_64/4.4/library/zlibbioc/include' -I/opt/R/x86_64/include -Xclang -fopenmp    -fPIC  -falign-functions=64 -Wall -g -O2   -c ChemmineOB.cpp -o ChemmineOB.o
In file included from ChemmineOB.cpp:1576:
/usr/local/include/openbabel3/openbabel/griddata.h:74:12: warning: 'OpenBabel::OBGridData::GetValue' hides overloaded virtual function [-Woverloaded-virtual]
    double GetValue(int i, int j, int k) const;
           ^
/usr/local/include/openbabel3/openbabel/base.h:228:32: note: hidden overloaded virtual function 'OpenBabel::OBGenericData::GetValue' declared here: different number of parameters (0 vs 3)
    virtual const std::string &GetValue()  const
                               ^
In file included from ChemmineOB.cpp:1576:
/usr/local/include/openbabel3/openbabel/griddata.h:76:12: warning: 'OpenBabel::OBGridData::GetValue' hides overloaded virtual function [-Woverloaded-virtual]
    double GetValue (vector3 pos) const;
           ^
/usr/local/include/openbabel3/openbabel/base.h:228:32: note: hidden overloaded virtual function 'OpenBabel::OBGenericData::GetValue' declared here: different number of parameters (0 vs 1)
    virtual const std::string &GetValue()  const
                               ^
In file included from ChemmineOB.cpp:1582:
/usr/local/include/openbabel3/openbabel/reaction.h:99:15: warning: 'OpenBabel::OBReaction::GetTitle' hides overloaded virtual function [-Woverloaded-virtual]
  std::string GetTitle()        const { return _title; }
              ^
/usr/local/include/openbabel3/openbabel/base.h:286:28: note: hidden overloaded virtual function 'OpenBabel::OBBase::GetTitle' declared here: different number of parameters (1 vs 0)
      virtual const char  *GetTitle(bool UNUSED(replaceNewlines) = true) const { return "";}
                           ^
In file included from ChemmineOB.cpp:1582:
/usr/local/include/openbabel3/openbabel/reaction.h:101:8: warning: 'OpenBabel::OBReaction::SetTitle' hides overloaded virtual function [-Woverloaded-virtual]
  void SetTitle(const std::string& title) { _title=title; }
       ^
/usr/local/include/openbabel3/openbabel/base.h:287:21: note: hidden overloaded virtual function 'OpenBabel::OBBase::SetTitle' declared here: type mismatch at 1st parameter ('const char *' vs 'const std::string &' (aka 'const basic_string<char> &'))
      virtual void  SetTitle(const char *) {}
                    ^
In file included from ChemmineOB.cpp:1587:
In file included from /usr/local/include/openbabel3/openbabel/obconversion.h:37:
In file included from /usr/local/include/openbabel3/openbabel/format.h:22:
/usr/local/include/openbabel3/openbabel/plugin.h:41:42: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
struct OBERROR CharPtrLess : public std::binary_function<const char*,const char*, bool>
                                    ~~~~~^~~~~~~~~~~~~~~
                                         __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:4160:7: warning: unused variable 'ecode' [-Wunused-variable]
  int ecode = 0; arg1 = (std::ios_base::event) swigarg_arg1; arg2 = (std::ios_base *) &swigarg_arg2; arg3 = (int) swigarg_arg3;
      ^
ChemmineOB.cpp:13728:45: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
SWIGEXPORT SEXP R_swig_new_dummy ( ) { std::binary_function< char const *,char const *,bool > *result = 0 ;
                                       ~~~~~^~~~~~~~~~~~~~~
                                            __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13730:18: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
  result = (std::binary_function< char const *,char const *,bool > *)new std::binary_function< char const *,char const *,bool >();
            ~~~~~^~~~~~~~~~~~~~~
                 __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13730:79: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
  result = (std::binary_function< char const *,char const *,bool > *)new std::binary_function< char const *,char const *,bool >();
                                                                         ~~~~~^~~~~~~~~~~~~~~
                                                                              __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13734:8: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
  std::binary_function< char const *,char const *,bool > *arg1 = (std::binary_function< char const *,char const *,bool > *) 0 ;
  ~~~~~^~~~~~~~~~~~~~~
       __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13734:72: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
  std::binary_function< char const *,char const *,bool > *arg1 = (std::binary_function< char const *,char const *,bool > *) 0 ;
                                                                  ~~~~~^~~~~~~~~~~~~~~
                                                                       __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:13739:34: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
   arg1 = reinterpret_cast< std::binary_function< char const *,char const *,bool > * >(argp1); delete arg1; r_ans = R_NilValue;
                            ~~~~~^~~~~~~~~~~~~~~
                                 __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
ChemmineOB.cpp:39656:27: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
    return (void *)((std::binary_function< char const *,char const *,bool > *)  ((OpenBabel::CharPtrLess *) x));
                     ~~~~~^~~~~~~~~~~~~~~
                          __binary_function
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
5 warnings and 8 errors generated.
make: *** [ChemmineOB.o] Error 1
ERROR: compilation failed for package ‘ChemmineOB’
* removing ‘/Users/ericscott/Library/R/x86_64/4.4/library/ChemmineOB’

The downloaded source packages are in
    ‘/private/var/folders/wr/by_lst2d2fngf67mknmgf4340000gn/T/RtmpNsDe6I/downloaded_packages’
Old packages: 'bslib', 'cachem', 'callr', 'desc', 'downlit', 'gert', 'gh', 'highr', 'htmltools', 'htmlwidgets', 'httpuv',
  'httr2', 'knitr', 'later', 'lifecycle', 'pkgbuild', 'pkgload', 'processx', 'promises', 'rmarkdown', 'sass', 'shiny',
  'stringi', 'stringr', 'systemfonts', 'testthat', 'tinytex', 'usethis', 'utf8', 'vctrs', 'waldo', 'withr', 'xfun',
  'xopen', 'yaml', 'zip', 'zlibbioc', 'foreign', 'KernSmooth', 'MASS', 'nlme', 'survival'
Update all/some/none? [a/s/n]: 
n
Warning message:
In install.packages(...) :
  installation of package ‘ChemmineOB’ had non-zero exit status

(I also noticed that the package version on the master branch is behind the version on Bioconductor.)

Aariq commented 3 months ago

Just made a dummy package with only ChemmineOB as a dependency and the build fails on macOS with the standard R CMD check GitHub action set up with usethis::use_github_action()

https://github.com/Aariq/testpkg/actions/runs/10203321875/job/28229398755#step:5:910 EDIT: even after I remembered to add a step to install OpenBabel it still fails: https://github.com/Aariq/testpkg/actions/runs/10203411288/job/28229686315#step:6:910

barracuda156 commented 3 months ago

@Aariq Since you are on a macOS, could you try with MacPorts? Or even manually, but borrow a fix from MacPorts.

That should work on every tested system (10.6 to 14.5).

Aariq commented 3 months ago

I can probably do that, but I doubt CRAN will. My package that depends on ChemmineOB will not likely pass the CRAN checks if I try to submit it. I'm able to install ChemmineOB from binary on my computer, so it's not really an issue of me not being able to use the package, it's an issue for me that CI is failing.

khoran commented 3 months ago

I have added -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION to the compiler arguments. It is available in devel version 1.43.1. I'm not sure I'm following all the issues in this discussion. If there is something else I can do, let me know.

Aariq commented 3 months ago

I successfully built it on my macbook with pak::pak("git::https://git.bioconductor.org/packages/ChemmineOB")! This version doesn't seem to have fully made it to Bioconductor yet (the devel page still shows 1.43.0), but I'll check back next week and see what happens if I just require 1.43.1 as a minimum version in a package.

barracuda156 commented 3 months ago

I have added -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION to the compiler arguments. It is available in devel version 1.43.1. I'm not sure I'm following all the issues in this discussion. If there is something else I can do, let me know.

@khoran I do not really get what that file is doing and why: https://github.com/girke-lab/ChemmineOB/blob/c65d028f5775d07e0b969f9e6e5979946a1a588c/src/Makevars.in

  1. Modern macOS uses libc++ by default, forcing -stdlib=libstdc++ is wrong.
  2. -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION is a libc++-specific flag, it should not be used with libstdc++.
  3. At least on macOS /usr/include is a system prefix, why would someone dump Eigen or OpenBabel headers there? Any sane package manager uses a dedicated prefix of its own. Nothing ever should install anything directly into /usr/include or /usr/lib, so there is no point in looking there either. (This may be different for BSD or Linux.)

Do I miss something?

Aariq commented 3 months ago

It looks like the macOS arm64 builds are still failing on Bioconductor even with the devel version, FYI: https://bioconductor.org/checkResults/devel/bioc-LATEST/ChemmineOB/kjohnson3-buildsrc.html

barracuda156 commented 3 months ago

It looks like the macOS arm64 builds are still failing on Bioconductor even with the devel version, FYI: https://bioconductor.org/checkResults/devel/bioc-LATEST/ChemmineOB/kjohnson3-buildsrc.html

If it actually uses args which I point to above, no surprise, it is expected to fail.

khoran commented 3 months ago

I have added -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION to the compiler arguments. It is available in devel version 1.43.1. I'm not sure I'm following all the issues in this discussion. If there is something else I can do, let me know.

@khoran I do not really get what that file is doing and why: https://github.com/girke-lab/ChemmineOB/blob/c65d028f5775d07e0b969f9e6e5979946a1a588c/src/Makevars.in

  1. Modern macOS uses libc++ by default, forcing -stdlib=libstdc++ is wrong.
  2. -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION is a libc++-specific flag, it should not be used with libstdc++.
  3. At least on macOS /usr/include is a system prefix, why would someone dump Eigen or OpenBabel headers there? Any sane package manager uses a dedicated prefix of its own. Nothing ever should install anything directly into /usr/include or /usr/lib, so there is no point in looking there either. (This may be different for BSD or Linux.)

Do I miss something?

The first several lines in Makevars.in are commented out, so do not apply. Therefore it is not forcing libstdc++.

The -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION was suggested in this thread as a solution to a compiler problem, and seems to be helping. If there is a better alternative, I'm happy to hear it.

I'm primarily a Linux developer, so I'm unfamiliar with Mac conventions. If you have a suggested revision to Makevars.in that works better, I'm happy to include it.

barracuda156 commented 3 months ago

@khoran Thank you for a clarification. Sorry, I should have noticed that initial lines were commented out. Need more caffeine.

The -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION was suggested in this thread as a solution to a compiler problem, and seems to be helping. If there is a better alternative, I'm happy to hear it.

Yes, this is a working solution for Clang (and possibly gcc when used with libc++), but I am not sure this flag is at least non-breaking with libstdc++. Does it work fine on Linux with gcc? If so, macOS should be good too, perhaps.

(I do not really know how to test for C++ runtime with autotools, sorry. But likely there is no macOS specifics here, a test should be generic and work regardless of OS.)

P. S. I will try to inject -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION into some gcc build just to see if it accepts it or errs out.