[R-SIG-Mac] [EXTERNAL] Re: Strange C/C++ Compile Errors

Wheeler, Matt (NIH/NIEHS) [E] m@tt@whee|er @end|ng |rom n|h@gov
Tue Dec 14 21:20:11 CET 2021


Apologies for not giving all of the information, but for such little information, you were able to find the problem.  In my haste to ‘fix’ the problem 11 months ago, I introduced a dumb dependency “gnu:stlib.h” that I forgot about. Thank you for your gracious reply.

Cheers,

Matt


From: Prof Brian Ripley <ripley using stats.ox.ac.uk>
Date: Tuesday, December 14, 2021 at 9:44 AM
To: Wheeler, Matt (NIH/NIEHS) [E] <matt.wheeler using nih.gov>, r-sig-mac using r-project.org <r-sig-mac using r-project.org>
Subject: [EXTERNAL] Re: [R-SIG-Mac] Strange C/C++ Compile Errors
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and are confident the content is safe.


You have not shown us the compiler command line used, nor made a
reproducible example available (and we might need both).

The suspicious line is

 > In file included from ./include/stdlib.h:36:

It looks like you may have a file in the package which is masking a
system header, but we don't have any information to go on.


On 14/12/2021 13:06, Wheeler, Matt (NIH/NIEHS) [E] via R-SIG-Mac wrote:
> I hope someone can help me with my C++/Rcpp compile issue. I am building a package, which will eventually be on CRAN, but I am currently looking to have it available to collaborators who use macOS. I have successfully compiled it for Linux and Windows (it passes the CRAN checks), but I have had no such luck for macOS. Here, I get strange compile errors based upon namespaces. For example, the first two errors are below:
>
>
>
> In file included from RcppExports.cpp:4:
>
> In file included from /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/RcppGSL/include/RcppGSL.h:25:
>
> In file included from /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/RcppGSL/include/RcppGSLForward.h:24:
>
> In file included from /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include/RcppCommon.h:30:
>
> In file included from /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include/Rcpp/r/headers.h:66:
>
> In file included from /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:100:
>
> In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
>
> In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:308:
>
> In file included from ./include/stdlib.h:36:
>
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstdlib:99:9: error: no member named 'size_t' in the global namespace
>
> using ::size_t;
>
>
>
> In file included from RcppExports.cpp:4:
>
> In file included from /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/RcppGSL/include/RcppGSL.h:25:
>
> In file included from /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/RcppGSL/include/RcppGSLForward.h:24:
>
> In file included from /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include/RcppCommon.h:30:
>
> In file included from /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include/Rcpp/r/headers.h:66:
>
> In file included from /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:153:
>
> In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/unordered_map:435:
>
> In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__hash_table:15:
>
> In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:673:
>
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:319:5: error: no member named 'posix_memalign' in the global namespace
>
>   ::posix_memalign(&__result, __alignment, __size);
>
>   ~~^
>
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:330:5: error: reference to unresolved using declaration
>
>   ::free(__ptr);
>
>
>
> Essentially, all of the errors are based upon namespace issues.
>
> I have seen that having a ~/.R/Makevars file messes things up, so I emptied that directory. I further have no h files in '/usr/local/include,'
>
> which will cause other build errors (i.e. I use NLOPT and GSL), but I want to get through this right now. Based upon other threads, I have the following for Xcode:
>
>
>
> %xcode-select -p
>
> /Library/Developer/CommandLineTools
>
> %xcrun --show-sdk-path
>
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
>
> %which clang
>
> /usr/bin/clang
>
>
>
> Now, this is happening on two Macs. The first is an M1 with macOS Monterey 12.01, and I got it with a clean IT build. The second is the one I use for work. It is an Intel using Catalina 10.15.7 (19H1519). I can understand why the second one may be messed up. When the issue occurred almost a year ago, I was in a research phase, couldn't figure out the solution, installed brew gcc and had R compile with this 'nonstandard' compiler with many no-no hacks. It was a hack, but it worked. Now, I need to distribute this to the masses, and it is still not working on a fresh machine and a newer version of macOS. Before I go further, I want to see if there is some setup issue on my machine(s), possibly something I need to talk about to IT.
>
>
>
> Further, the file RcppExports.cpp is automatically generated in Rcpp, so I don't think it is a code issue, but it is a dependency issue with clang, but here I am not knowledgeable enough to fix. Quite honestly, Apple�s compiler setup is baffling, but I am used to /usr/include/ etc.   I can also compile Rcpp from source code, and I have compiled other packages on these machines.
>
>
>
> Thanks in advance,
>
>
>
> Matt
>
>
>       [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac


--
Brian D. Ripley,                  ripley using stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford

_______________________________________________
R-SIG-Mac mailing list
R-SIG-Mac using r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

	[[alternative HTML version deleted]]



More information about the R-SIG-Mac mailing list