[R-SIG-Mac] The Equivalent of pkg-config for Frameworks

Simon Urbanek simon.urbanek at r-project.org
Fri May 30 16:36:57 CEST 2014


On May 30, 2014, at 6:07 AM, Dominic Steinitz <dominic at steinitz.org> wrote:

> My googling skills are failing. I want to install a package which relies on R. This currently works on windows and linux. When I try it on my macbook I get told
> 
>> Configuring H-0.1.0.0... 
>> Warning: Instead of 'ghc-options: -cpp' use 'extensions: CPP' 
>> cabal: The pkg-config package 'libR' version >=3.0 is required but it 
>> could 
>> not be found. 
>> Failed to install H-0.1.0.0 
>> Updating documentation index /Users/dom/Library/Haskell/doc/index.html 
>> cabal: Error: some packages failed to install: 
>> H-0.1.0.0 failed during the configure step. The exception was: 
>> ExitFailure 1 
> 
> But I have R installed
> 
>> $ R --version 
>> R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" 
>> Copyright (C) 2013 The R Foundation for Statistical Computing 
>> Platform: x86_64-apple-darwin10.8.0 (64-bit) 
> 
> 
> It seems the installer for the package uses pkg-config to check for the existence of R.
> 
>> $ pkg-config --version
>> 0.28
> 
> 
> It finds e.g. the gnu scientific library
> 
>> $ pkg-config  --libs gsl
>> -L/usr/local/Cellar/gsl/1.16/lib -lgsl -lgslcblas -lm
> 
> 
> But can’t find R
> 
>> $ pkg-config  --libs R
>> Package R was not found in the pkg-config search path.
>> Perhaps you should add the directory containing `R.pc'
>> to the PKG_CONFIG_PATH environment variable
>> No package 'R' found
> 
> 
> On my installation, R lives in
> 
>> /Library/Frameworks/R.framework
> 
> In order to use pkg-config, it seems I need a .pc file somewhere but I can’t find one.
> 
> Can someone either tell me where the .pc file is for R or alternatively how to tell the installer where to find R?
> 

Mac OS X has no pkg-config, so that's why native version of R has no R.pc. It seems that whatever you are compiling doesn't have native OS X support. Since you are already mixing brewed and native code, you may as well just use brew entirely since you've already entered murky waters. I didn't test, but I would presume that it gives you a non-framework installation of R which may provide R.pc.

How to tell the installer to find R is a question you should pose to the authors of whatever you're trying to compile, R has no control over that. Note that the canonical way to obtain R flags is via `R CMD config` so I'd say this is a bug in the package you're compiling - it should be using R CMD config --cppflags and R CMD config --ldflags instead of pkg-config -- it may use pkg-config as a fallback, but is should support R CMD config in the first place.

Finally, you could hand-craft libR.pc which points to the native installation of R - it could look something like

rhome=/Library/Frameworks/R.framework/Resources
rincludedir=/Library/Frameworks/R.framework/Headers

Name: libR
Description: R as a library
Version: 3.1.0
Libs: -F/Library/Frameworks/R.framework/.. -framework R -llzma -lz -licucore -lm -liconv
Cflags: -I${rincludedir}
Libs.private:

Untested and, again, the proper way is to use

R CMD config --cppflags
R CMD config --ldflags

Cheers,
Simon



> Many thanks
> 
> Dominic Steinitz
> dominic at steinitz.org
> http://idontgetoutmuch.wordpress.com
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 



More information about the R-SIG-Mac mailing list