Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rextlfung opened this issue Mar 14, 2024 · 27 comments
Open

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

rextlfung opened this issue Mar 14, 2024 · 27 comments

Comments

@rextlfung
Copy link

rextlfung commented Mar 14, 2024

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
Copy link
Member

hcmh commented Mar 14, 2024

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
Copy link
Author

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
Copy link
Member

hcmh commented Mar 14, 2024

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
Copy link
Author

rextlfung commented Mar 14, 2024

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 <fftw3.h>
| ^~~~~~~~~
compilation terminated.

@hcmh
Copy link
Member

hcmh commented Mar 15, 2024

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
Copy link
Author

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
Copy link

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

@hcmh
Copy link
Member

hcmh commented Mar 22, 2024

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
Copy link

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
Copy link
Member

hcmh commented Mar 22, 2024

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
Copy link

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

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

@hcmh
Copy link
Member

hcmh commented Mar 22, 2024

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
Copy link

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
Copy link
Member

hcmh commented Mar 22, 2024

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
Copy link

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
Copy link
Member

hcmh commented Mar 22, 2024

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

@hongzeyu0319
Copy link

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 <cblas_openblas.h>
| ^~~~~~~~~~~~~~~~~~
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
Copy link
Member

hcmh commented Mar 22, 2024

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
Copy link
Member

jtamir commented Mar 22, 2024 via email

@jtamir
Copy link
Member

jtamir commented Mar 22, 2024 via email

@hongzeyu0319
Copy link

@hcmh @jtamir Thanks for help!

@rextlfung
Copy link
Author

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
Copy link

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
Copy link
Member

hcmh commented Mar 22, 2024

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
Copy link
Author

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

@hcmh
Copy link
Member

hcmh commented Mar 22, 2024

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants