[Rcpp-devel] Cannot run rcpp due to missing include file(s)
Paul Fishwick
metaphorz at gmail.com
Mon May 4 12:37:13 CEST 2020
Simon. I’ll do that. Thanks. Paul
Paul Fishwick, PhD
Distinguished University Chair of Arts, Technology, and Emerging Communication
Professor of Computer Science
Director, Creative Automata Laboratory
The University of Texas at Dallas
Arts & Technology
800 West Campbell Road, AT10
Richardson, TX 75080-3021
Home: utdallas.edu/atec/fishwick
Media: medium.com/@metaphorz
Modeling: digest.sigsim.org
Twitter: @PaulFishwick
> On May 4, 2020, at 2:39 AM, Simon Urbanek <simon.urbanek at r-project.org> wrote:
>
> Paul,
>
> as Kevin pointed out you have a big mess in /usr/local - I'd recommend renaming /usr/local/include and /usr//local/lib -- then you shouldn't need to set any custom flags at all (at least in R 4.0.0).
>
> Cheers,
> Simon
>
>
>> On 4/05/2020, at 9:34 AM, Paul Fishwick <metaphorz at gmail.com> wrote:
>>
>> @Kevin: This worked great. Thanks. I deleted the line in ~/.R/Makevars and inserted the line
>> defining CPPFLAGS as you suggested. Rcpp now works in R! I have not yet tried to compile
>> a package from source in R but I am guessing (or hoping) that should now work.
>>
>> In the mean time, I will read up on the R.framework.......Makeconf file to understand it.
>>
>> I suppose since /usr/local/include is the offending set of headers, I could just delete
>> everything from that directory too (after making a backup). I am not doing any other
>> development work except for R/Rcpp, so perhaps it will not make a difference.
>>
>> However, since your suggested line does work, I'll leave it at this, and see if I can
>> build up my knowledge on conflicting include files.
>>
>> Thanks again!
>>
>> -paul
>>
>>
>>
>>
>> On 5/3/20, 2:51 PM, "Kevin Ushey" <kevinushey at gmail.com> wrote:
>>
>>> In file included from /usr/local/include/math.h:8:
>>
>> The problem here is you have a bunch of headers in /usr/local/include
>> that are shadowing / overriding the "normal" system header files;
>> /usr/local/include/math.h being one of these (but I imagine there's
>> more).
>>
>> To work around this, you'll have to explicitly remove the
>> -I/usr/local/include bit that's part of CPPFLAGS (normally set by
>> default by an R installation), or clean up your /usr/local/include
>> directory. For example, in ~/.R/Makevars, you could set:
>>
>> CPPFLAGS = -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
>>
>> See the Makeconf file at:
>>
>> /Library/Frameworks/R.framework/Resources/etc/Makeconf
>>
>> for more information on where the default values for compilation flags
>> come from.
>>
>> Note that setting the above will probably break compilation for other
>> packages that depend on headers being located in /usr/local/include;
>> if that is indeed the case your main recourse would be to clean up
>> /usr/local/include, or find a way to explicitly include your system
>> headers before /usr/local/include.
>>
>> As an aside, the Makevars variables prefixed with PKG_ are normally
>> reserved for use by package authors (in their own src/Makevars); you
>> normally shouldn't try to set or override those. See in R-exts:
>>
>> https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Using-Makevars
>>
>> for more details.
>>
>> Best,
>> Kevin
>>
>> On Sun, May 3, 2020 at 10:17 AM Paul Fishwick <metaphorz at gmail.com> wrote:
>>>
>>> It was a good suggestion. I went back to installing R 4.0 as you suggested. In Rstudio, which I think
>>>
>>> uses whatever R happens to be currently installed, I get into
>>>
>>> a similar rcpp issue whenever I say “y” to compiling packages from source. There seems
>>>
>>> to be consistent disconnect of R finding certain files when compilation with
>>>
>>> clang is required.
>>>
>>>
>>>
>>> …………
>>>
>>>
>>>
>>> clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/usr/local/include -fPIC -Wall -g -O2 -c capture.c -o capture.o
>>>
>>> In file included from capture.c:1:
>>>
>>> In file included from /Library/Frameworks/R.framework/Resources/include/Rinternals.h:44:
>>>
>>> In file included from /Library/Frameworks/R.framework/Resources/include/R_ext/Arith.h:41:
>>>
>>> In file included from /usr/local/include/math.h:8:
>>>
>>> In file included from /usr/local/include/features.h:10:
>>>
>>> /usr/local/include/forwards.h:10:10: fatal error: 'config.h' file not found
>>>
>>> #include "config.h"
>>>
>>> ^~~~~~~~~~
>>>
>>> 1 error generated.
>>>
>>> make: *** [capture.o] Error 1
>>>
>>> ERROR: compilation failed for package ‘rlang’
>>>
>>>
>>>
>>> ………………….
>>>
>>>
>>>
>>> From: Carl Ganz <carlganz at gmail.com>
>>> Date: Sunday, May 3, 2020 at 12:04 PM
>>> To: Paul Fishwick <metaphorz at gmail.com>
>>> Cc: <rcpp-devel at lists.r-forge.r-project.org>
>>> Subject: Re: [Rcpp-devel] Cannot run rcpp due to missing include file(s)
>>>
>>>
>>>
>>> This is probably beyond my understanding at this point, but the solution I offered worked for me with R 4.0 and it looks like this example is R 3.6
>>>
>>>
>>>
>>> I vaguely remember some issues with interaction between older R version and newer Xcode 11.4.1 so moving to R 4 might help
>>>
>>>
>>>
>>>> On Sun, May 3, 2020 at 9:25 AM Paul Fishwick <metaphorz at gmail.com> wrote:
>>>
>>> Carl
>>>
>>> First, thank you for this quick tip! I had no ~/.R directory and Makevars didn’t exist when I searched
>>>
>>> for it in Finder. So, I made the directdory ~/.R and then added a new file “Makevars” to that directory.
>>>
>>> I edited this file to add your PKG_CPPFLAGS:
>>>
>>>
>>>
>>> (base) <hostname>-5:.R paul$ more Makevars
>>>
>>> PKG_CPPFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
>>>
>>>
>>>
>>> Now I get another sequence of compiler errors. I’ll include only the first several lines:
>>>
>>>
>>>
>>> ……….
>>>
>>>
>>>
>>> In file included from fileb6e52d3a23c3.cpp:1:
>>>
>>> In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp.h:27:
>>>
>>> In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/RcppCommon.h:29:
>>>
>>> In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/r/headers.h:67:
>>>
>>> In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:100:
>>>
>>> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: error: no member named 'signbit' in the global namespace
>>>
>>> using ::signbit;
>>>
>>> ~~^
>>>
>>> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'fpclassify' in the global namespace
>>>
>>> using ::fpclassify;
>>>
>>> ~~^
>>>
>>> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
>>>
>>> using ::isfinite;
>>>
>>> ~~^
>>>
>>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: 'finite' declared here
>>>
>>> extern int finite(double)
>>>
>>> ^
>>>
>>>
>>>
>>> From: Carl Ganz <carlganz at gmail.com>
>>> Date: Sunday, May 3, 2020 at 11:02 AM
>>> To: Paul Fishwick <metaphorz at gmail.com>
>>> Cc: <rcpp-devel at lists.r-forge.r-project.org>
>>> Subject: Re: [Rcpp-devel] Cannot run rcpp due to missing include file(s)
>>>
>>>
>>>
>>> I experienced similar issues on Mac and was able to fix by adding PKG_CPPFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include to my .R/Makevars
>>>
>>>
>>>
>>> My understanding is that Mac no longer uses the /usr/local/include so you need to point it to the usr/include in the Developer SDK folder
>>>
>>>
>>>
>>>> On Sun, May 3, 2020 at 8:59 AM Paul Fishwick <metaphorz at gmail.com> wrote:
>>>
>>>
>>>
>>>
>>> System: Mac OSX 11 (Catalina), Rstudio with R version 3.6.3 (but have also tried 4.0 and 3.3),
>>>
>>> Xcode version 11.4.1
>>>
>>>
>>>
>>> Went to: http://adv-r.had.co.nz/Rcpp.html#rcpp-intro
>>>
>>>
>>>
>>> and tried library(rcpp) which worked fine because I previously had installed the rcpp package.
>>>
>>>
>>>
>>> The following yields an error in finding config.h. I did a "find" on config.h and sure enough it is not
>>>
>>> in the clang++ -I directory references. Here is what I have tried:
>>>
>>>
>>>
>>> Installing Xcode's command line tools (which were installed using xcode-select --install)
>>>
>>> Also, downloaded and installed the version of clang8 and gfortran6.1 from:
>>>
>>>
>>>
>>> https://cran.r-project.org/bin/macosx/tools/
>>>
>>>
>>>
>>> The following error occurs when I try this rcpp example from Hadley but it also happens whenever
>>>
>>> I try to install an R package from source. The compile fails due to not finding some include file.
>>>
>>>
>>>
>>> I would have thought that installing clang8 would have also included the proper include (.h) file directories
>>>
>>> with their contents needed by R.
>>>
>>>
>>>
>>> Is there something I am missing below? Thank you.
>>>
>>>
>>>
>>>> library(Rcpp)
>>>> cppFunction('int add(int x, int y, int z) {
>>> + int sum = x + y + z;
>>> + return sum;
>>> + }')
>>> In file included from fileb6e52d3a23c3.cpp:1:
>>> In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp.h:27:
>>> In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/RcppCommon.h:29:
>>> In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/r/headers.h:67:
>>> In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:100:
>>> In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:304:
>>> In file included from /usr/local/include/math.h:8:
>>> In file included from /usr/local/include/features.h:10:
>>> /usr/local/include/forwards.h:10:10: fatal error: 'config.h' file not found
>>> #include "config.h"
>>> ^~~~~~~~~~
>>> 1 error generated.
>>> make: *** [fileb6e52d3a23c3.o] Error 1
>>> clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -I"/private/var/folders/bt/1gd00p5s6n19m_bgh9b04gxc0000gp/T/RtmpRRyaky/sourceCpp-x86_64-apple-darwin15.6.0-1.0.4" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c fileb6e52d3a23c3.cpp -o fileb6e52d3a23c3.o
>>> Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, :
>>> Error 1 occurred building shared library.
>>>>
>>>
>>> _______________________________________________
>>> Rcpp-devel mailing list
>>> Rcpp-devel at lists.r-forge.r-project.org
>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>>>
>>> _______________________________________________
>>> Rcpp-devel mailing list
>>> Rcpp-devel at lists.r-forge.r-project.org
>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>>
>>
>> _______________________________________________
>> Rcpp-devel mailing list
>> Rcpp-devel at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20200504/96d45529/attachment-0001.html>
More information about the Rcpp-devel
mailing list