mrirecon / bart

BART: Toolbox for Computational Magnetic Resonance Imaging
https://mrirecon.github.io/bart/
BSD 3-Clause "New" or "Revised" License
291 stars 161 forks source link

M1 Mac compile error: "Makefile:23: *** missing separator. Stop." #326

Open rextlfung opened 5 months ago

rextlfung commented 5 months ago

I'm trying to use Homebrew to install BART on an apple silicon computer but am encountering the following error when attempting to compile the code:

Makefile:23: *** missing separator. Stop.

I am unfamiliar with the Makefile syntax. Any ideas on how to fix this?

Thanks

hcmh commented 5 months ago

Hey, since I added that line, I might have made a mistake there. Could you just comment out that line (prefix it with # ) and try again? For debugging your issue, that should not break anything important.

Additionally, can you post the output of make --version ?

rextlfung commented 5 months ago

Hi,

I commented out that line and am now running into: clang: error: unsupported option '-fopenmp'

The output of make --version is:

GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

hcmh commented 5 months ago

Oh, that is a truly ancient version of GNU make. That might be the issue.

Did you follow the instructions in the README (not README.md) for Mac OS? (see here)

That should install a supported version of both gcc or clang and of make.

rextlfung commented 5 months ago

I see. I just followed these instructions in the README, which I guess doesn't update make:

Using HomeBrew (https://brew.sh):

$ brew install --cask gcc-arm-embedded
$ brew install libpng
$ brew install fftw
$ brew install openblas

Select gcc as the compiler when building:
$ CC=gcc make

Instead, I used brew to install gmake, which seemed to fix the issue but now I am encountering this error:

/bart/src/bart.c:50:10: fatal error: fftw3.h: No such file or directory 50 | #include | ^~~~~ compilation terminated.

hcmh commented 5 months ago

Hmm, strange. Then we should probably add that to the instructions.

To your new problem: I would guess that $ brew install fftw should fix that?

rextlfung commented 5 months ago

I already tried that. I believe that it has something to do with fftw being installed on my machine but not being seen by the compiler. I will try to figure that out and post the solution here.

hongzeyu0319 commented 5 months ago

I'm having the exact same issue here on my m1 mac

hcmh commented 5 months ago

Ok, then we probably need to adapt where bart looks for fftw.

Could you try: find /opt /usr -iname fftw3.h, to see where fftw is located? (I hope that find exists on Mac OS)

hongzeyu0319 commented 5 months ago

Ok, then we probably need to adapt where bart looks for fftw.

Could you try: find /opt /usr -iname fftw3.h, to see where fftw is located? (I hope that find exists on Mac OS)

IIt's found here /opt/homebrew/include/fftw3.h /opt/homebrew/Cellar/fftw/3.3.10_1/include/fftw3.h

hcmh commented 5 months ago

Ok, that is not where we expect it. You could try compiling with CC=gcc FFTW_BASE=/opt/homebrew makeand see if that fixes the problem.

And if you not, please also post the compiler command that failed

hongzeyu0319 commented 5 months ago

I'm still having the '-fopenmp" unsupported error...

clang: error: unsupported option '-fopenmp' make: *** [/Users/yuhongze/git/bart/src/bart.o] Error 1

hcmh commented 5 months ago

That error should not be possible when passing CC=clang. What are the lines directly before that message? Those should show the command line that was passed to the compiler, in addition to which compiler was used. (some like this: gcc -Wall -Wextra -g -MMD -MF src/.bart.d -iquote /home/ch/bart/src/ -I/usr//include -DFFTWTHREADS -I/usr//include/ -Og -Wmissing-prototypes -Wno-vla-parameter -Wno-nonnull -Wno-maybe-uninitialized -g -std=gnu11 -fopenmp -c -o src/bart.o src/bart.c )

Edit: Did you do brew install --cask gcc-arm-embeddedand pass CC=gccto make?

hongzeyu0319 commented 5 months ago

Yes I did pass CC=gcc to make. I re-followed the instructions in README for mac-os but still have this error

gcc -Wall -Wextra -DUSE_MACPORTS -MMD -MF /Users/yuhongze/git/bart/src/.bart.d -iquote /Users/yuhongze/git/bart/src/ -I/opt/local//include/ -I/opt/local//include -DFFTWTHREADS -DMAIN_LIST="avg, bench, bin, bitmask, cabs, calc, caldir, calmat, carg, casorati, cc, ccapply, cdf97, circshift, conj, conv, conway, copy, cpyphs, creal, crop, delta, ecalib, ecaltwo, epg, estdelay, estdims, estshift, estvar, extract, fakeksp, fft, fftmod, fftrot, fftshift, filter, flatten, flip, fmac, fovshift, homodyne, ictv, index, invert, itsense, join, looklocker, lrmatrix, mandelbrot, measure, mip, mnist, moba, mobafit, morphop, multicfl, nlinv, nlinvnet, nlmeans, nnet, noise, normalize, nrmse, nufft, nufftbase, onehotenc, ones, pattern, phantom, pics, pocsense, poisson, pol2mask, poly, psf, reconet, repmat, reshape, resize, rmfreq, rof, roistat, rovir, rss, rtnlinv, sake, saxpy, scale, sdot, show, signal, sim, slice, spow, sqpics, squeeze, ssa, std, svd, tensorflow, tgv, threshold, toimg, traj, transpose, twixread, upat, var, vec, version, walsh, wave, wavelet, wavepsf, whiten, window, wshfl, zeros, zexp, ()" -include src/main.h -O2 -Wmissing-prototypes -Wuseless-cast -Wno-c2x-extensions -std=gnu11 -fopenmp -c -o /Users/yuhongze/git/bart/src/bart.o /Users/yuhongze/git/bart/src/bart.c clang: error: unsupported option '-fopenmp' make: *** [/Users/yuhongze/git/bart/src/bart.o] Error 1

hcmh commented 5 months ago

Nice, on Mac OS, /usr/bin/gccis actually clang. Great, thank you Apple.

So we need to find out where the gcc that you installed with brew install --cask gcc-arm-embedded actually is.

Could you run find /usr /opt -iname gcc and find /usr /opt -iname gcc-\* for me?

hongzeyu0319 commented 5 months ago

Sure, here is the output:

(base) yuhongze@STOP-PROCRASNATING bart % find /usr /opt -iname gcc /usr/bin/gcc find: /usr/sbin/authserver: Permission denied /usr/share/file/magic/gcc /opt/homebrew/var/homebrew/linked/gcc /opt/homebrew/Library/Homebrew/shims/mac/super/gcc /opt/homebrew/Library/Homebrew/shims/super/gcc /opt/homebrew/Library/Homebrew/shims/linux/super/gcc /opt/homebrew/lib/gcc /opt/homebrew/opt/gcc /opt/homebrew/Cellar/gcc /opt/homebrew/Cellar/gcc/13.2.0/libexec/gcc /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/13/gcc find: /opt/cisco/anyconnect/temp/downloader: Permission denied (base) yuhongze@STOP-PROCRASNATING bart % find /usr /opt -iname gcc-* find: /usr/sbin/authserver: Permission denied /opt/homebrew/bin/gcc-13 /opt/homebrew/bin/gcc-nm-13 /opt/homebrew/bin/gcc-ar-13 /opt/homebrew/bin/gcc-ranlib-13 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-4.9 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-13 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-12 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-5 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-10 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-11 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-4.2 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-8 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-6 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-7 /opt/homebrew/Library/Homebrew/shims/mac/super/gcc-9 /opt/homebrew/Library/Homebrew/shims/super/gcc-4.9 /opt/homebrew/Library/Homebrew/shims/super/gcc-13 /opt/homebrew/Library/Homebrew/shims/super/gcc-12 /opt/homebrew/Library/Homebrew/shims/super/gcc-5 /opt/homebrew/Library/Homebrew/shims/super/gcc-10 /opt/homebrew/Library/Homebrew/shims/super/gcc-11 /opt/homebrew/Library/Homebrew/shims/super/gcc-8 /opt/homebrew/Library/Homebrew/shims/super/gcc-6 /opt/homebrew/Library/Homebrew/shims/super/gcc-7 /opt/homebrew/Library/Homebrew/shims/super/gcc-9 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-4.9 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-13 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-12 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-5 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-10 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-11 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-4.2 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-8 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-6 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-7 /opt/homebrew/Library/Homebrew/shims/linux/super/gcc-9 /opt/homebrew/Caskroom/gcc-arm-embedded /opt/homebrew/Caskroom/gcc-arm-embedded/.metadata/13.2.rel1/20231220170548.510/Casks/gcc-arm-embedded.json /opt/homebrew/Cellar/gcc/13.2.0/bin/gcc-13 /opt/homebrew/Cellar/gcc/13.2.0/bin/gcc-nm-13 /opt/homebrew/Cellar/gcc/13.2.0/bin/gcc-ar-13 /opt/homebrew/Cellar/gcc/13.2.0/bin/gcc-ranlib-13 /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13/plugin/include/ada/gcc-interface /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13/plugin/include/gcc-plugin.h /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13/plugin/include/gcc-rich-location.h /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13/plugin/include/gcc-symtab.h /opt/homebrew/Cellar/gcc/13.2.0/share/man/man1/gcc-13.1 /opt/homebrew/Cellar/gcc/13.2.0/share/gcc-13 /opt/homebrew/share/man/man1/gcc-13.1 /opt/homebrew/share/gcc-13

hcmh commented 5 months ago

Thank you! so CC=gcc-13 or possibly CC=/opt/homebrew/bin/gcc-13 should do the trick for that error.

hongzeyu0319 commented 5 months ago

Sorry for trouble you again, I tried CC=/opt/homebrew/bin/gcc-13 make FFTW_BASE=/opt/homebrew which solves the previous two issues, but now it's not able to find openblas, as

(base) yuhongze@STOP-PROCRASNATING bart % CC=/opt/homebrew/bin/gcc-13 make FFTW_BASE=/opt/homebrew /opt/homebrew/bin/gcc-13 -Wall -Wextra -DUSE_MACPORTS -MMD -MF /Users/yuhongze/git/bart/src/num/.blas.d -iquote /Users/yuhongze/git/bart/src/ -I/opt/homebrew/include/ -I/opt/local//include -DFFTWTHREADS -DMAIN_LIST="avg, bench, bin, bitmask, cabs, calc, caldir, calmat, carg, casorati, cc, ccapply, cdf97, circshift, conj, conv, conway, copy, cpyphs, creal, crop, delta, ecalib, ecaltwo, epg, estdelay, estdims, estshift, estvar, extract, fakeksp, fft, fftmod, fftrot, fftshift, filter, flatten, flip, fmac, fovshift, homodyne, ictv, index, invert, itsense, join, looklocker, lrmatrix, mandelbrot, measure, mip, mnist, moba, mobafit, morphop, multicfl, nlinv, nlinvnet, nlmeans, nnet, noise, normalize, nrmse, nufft, nufftbase, onehotenc, ones, pattern, phantom, pics, pocsense, poisson, pol2mask, poly, psf, reconet, repmat, reshape, resize, rmfreq, rof, roistat, rovir, rss, rtnlinv, sake, saxpy, scale, sdot, show, signal, sim, slice, spow, sqpics, squeeze, ssa, std, svd, tensorflow, tgv, threshold, toimg, traj, transpose, twixread, upat, var, vec, version, walsh, wave, wavelet, wavepsf, whiten, window, wshfl, zeros, zexp, ()" -include src/main.h -O2 -Wmissing-prototypes -Wno-vla-parameter -Wno-nonnull -Wno-maybe-uninitialized -std=gnu11 -fopenmp -c -o /Users/yuhongze/git/bart/src/num/blas.o /Users/yuhongze/git/bart/src/num/blas.c /Users/yuhongze/git/bart/src/num/blas.c:19:10: fatal error: cblas_openblas.h: No such file or directory 19 | #include | ^~~~~~ compilation terminated. make: *** [/Users/yuhongze/git/bart/src/num/blas.o] Error 1

I tried to follow the instructions on how to find fftw3.h to find it like find /opt /usr -iname cblas_openblas.h, which returns nothing. While I'm able to find openblas: (base) yuhongze@STOP-PROCRASNATING bart % find /opt /usr -iname openblas
/opt/homebrew/opt/openblas /opt/homebrew/Cellar/openblas /opt/homebrew/Cellar/openblas/0.3.26/lib/cmake/openblas>

hcmh commented 5 months ago

Oh, that is because it defaults to MACPORTS=1. Maybe pass MACPORTS=0 as well.

By the way, instead of passing all of those arguments by hand, you can also create a file called Makefile.localand write them in there (one per line)

jtamir commented 5 months ago

Hi all,

I am just jumping on this thread. I want to mention that there are different ways of installing the packages, either with Macports or with Homebrew, and the library paths will differ. We have a flag that defaults to MACPORTS=1. We should fix the pathing issues while making sure both cases work.

Therefore if you are using Homebrew then I recommend first setting MACPORTS=1, and then modifying the paths under that logic.

For the “Missing Separator” error, this can be resolved by installing the package gmake. With Macports (port install gmake), I can then compile the master branch of BART with the command “gmake” (and MACPORTS=1).

Jon Tamir, PhD Assistant Professor Jack Kilby/Texas Instruments Endowed Faculty Fellowship in Computer Engineering Chandra Family Department of Electrical and Computer Engineering The University of Texas at Austin

www.jtsense.comhttp://www.jtsense.com/

jtamir commented 5 months ago

Sorry for my typo. For Homebrew, set MACPORTS=0.

hongzeyu0319 commented 5 months ago

@hcmh @jtamir Thanks for help!

rextlfung commented 5 months ago

Thanks for all your help! @hongzeyu0319 did you manage to fix the error with the blas header files not being found?

I'm currently running gmake with the following flags:

CC=/opt/homebrew/bin/gcc-13
MACPORTS=0
FFTW_BASE=/opt/homebrew
OPENBLAS_BASE=/opt/homebrew

but it gives me the following error: fatal error: cblas.h: No such file or directory

hongzeyu0319 commented 5 months ago

Thanks for all your help! @hongzeyu0319 did you manage to fix the error with the blas header files not being found?

I'm currently running gmake with the following flags:

CC=/opt/homebrew/bin/gcc-13
MACPORTS=0
FFTW_BASE=/opt/homebrew
OPENBLAS_BASE=/opt/homebrew

but it gives me the following error: fatal error: cblas.h: No such file or directory

I'm still seeing this issue too, I haven't tried to look intio it after that

hcmh commented 5 months ago

OPENBLAS_BASE=/opt/homebrewshould be BLAS_BASE=/opt/homebrew instead. But does /opt/homebrew/include/cblas.hexist? Or where do you find cblas.h?

rextlfung commented 5 months ago

Indeed there is no cblas.h but I have clblas.h, which appears to be what's available on Homebrew.

hcmh commented 5 months ago

clblas.h is not what we need.

brew install openblas

Should install what we need, but I have no idea where homebrew installs those things..

rextlfung commented 5 months ago

I see. I have openblas installed but there is appears to be no cblas.h under /opt/homebrew/include/

There appears to be a cblas.h under /opt/homebrew/Cellar/openblas/0.3.26/include/ though