简体   繁体   中英

FFTW linking issue in R 3.2.2 running on Mac OS X 10.10.5 Yosemite

I am trying to resolve what seems to be a dependency on fftw for a package that should run in R 3.2.2. The package's authors claims this dependency does not exist anymore, but when I try to install the package I receive the following output

> install.packages("seewave")
Package which is only available in source form, and may need
 compilation of C/C++/Fortran: ‘seewave’
Do you want to attempt to install these from sources?
y/n: y
installing the source package ‘seewave’

trying URL 'https://cran.rstudio.com/src/contrib/seewave_2.0.2.tar.gz'
Content type 'application/x-gzip' length 2485930 bytes (2.4 MB)
==================================================
downloaded 2.4 MB

* installing *source* package ‘seewave’ ...
** package ‘seewave’ successfully unpacked and MD5 sums checked
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
-I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include
-fPIC  -Wall -mtune=core2 -g -O2  -c stft.c -o stft.o 
stft.c:44:6: warning: unused variable 'i' [-Wunused-variable] 
       int i = 0; 
           ^ 
1 warning generated.
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress 
-L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib  
-o seewave.so stft.o -lfftw3 -lsndfile  
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: library not found for -lfftw3
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [seewave.so] Error 1
ERROR: compilation failed for package ‘seewave’
* removing        /Library/Frameworks/R.framework/Versions/3.2/Resources/library/seewave’
Warning in install.packages :
installation of package ‘seewave’ had non-zero exit status

A package named fftw is already in R, in the version 1.0.3. However, when I go into the terminal and type the command below, I receive an output pointing to the lack of 'linking' of fftw

$ brew install fftw
Warning: fftw-3.3.4_1 already installed, it's just not linked

Interestingly (or foolishly), there is a fftw3 folder in a surely incorrect path, but there is not a path for fftw3.3.4_1

/Users/mario/fftw-3.3.3

How could I make the correct linking and perhaps solve the problem?

Thanks in advance

This looks like you may have previously attempted to install FFTW from source, owing to the presence of /Users/mario/fftw-3.3.3 and the fact the Homebrew version is not linked. If you have previously installed FFTW from source brew doctor should output something similar to

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
    /usr/local/include/fftw3.h

Note: There should be more warnings for a correct installation.

When you download and extract FFTW the resulting folder will have the name fftw-<major>.<minor>.<patch> . This is most likely what /Users/mario/fftw-3.3.3 is. You should be able to uninstall this version of FFTW with

$ cd /Users/mario/fftw-3.3.3
$ make uninstall
$ cd ..
$ rm -rf fftw-3.3.3/

Note: sudo may be needed depending on how you installed it. If no makefile exists you will need to create it with

$ ./configure
$ make uninstall

Now brew doctor should not output anything about FFTW and you can safely execute

$ brew link fftw

to link FFTW. If, on the off-chance, this still does not work you can use

$ brew link --overwrite --dry-run fftw

This will, because of --dry-run , tell you what files Homebrew will need to overwrite to correctly link FFTW.

$ brew link --overwrite fftw

should then be safe to run as Homebrew is designed not to mess up your system. Now the issues with linking FFTW when installing the R package should be resolved and your installation should proceed as expected.


Aside

Using sudo with brew link is never the right option. The correct method for linking Homebrew formulas is as described above.

  1. Correct any warnings from brew doctor
  2. Check what brew link --overwrite --dry-run will overwrite
  3. Link formula with brew link or brew link --overwrite

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM