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

Compilation issues on the latest macOS Monterey (M1 Mac) #90

Open
bodkan opened this issue Apr 22, 2022 · 2 comments
Open

Compilation issues on the latest macOS Monterey (M1 Mac) #90

bodkan opened this issue Apr 22, 2022 · 2 comments

Comments

@bodkan
Copy link

bodkan commented Apr 22, 2022

Background

I just encountered some issues while compiling ADMIXTOOLS on a freshly unpacked M1 MacBook Pro running macOS Monterey Version 12.3.1 (openblas and gsl installed from Homebrew). The problem manifests both on the latest development commit of ADMIXTOOLS from GitHub as well as on the latest tagged v7.0.2 release.

Description of the problem # 1

The usual combination of cd src/ && make clobber && make install leads to:

[ ... snip ... ]

clang: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
admutils.c:459:9: error: implicitly declaring library function 'finite' with type 'int (double)' [-Werror,-Wimplicit-function-declaration]
   if (!finite(a[i])) fatalx("(testnan) fails:  index %d\n",i) ;
        ^
admutils.c:459:9: note: include the header <math.h> or explicitly provide a declaration for 'finite'
admutils.c:885:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
admutils.c:1114:28: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
    printf("(setid2pops): %s not found\n") ;
                          ~^
2 warnings and 1 error generated.
make: *** [admutils.o] Error 1

Solution to the problem # 1

I found out that the latest macOS compiler infrastructure provided by Xcode no longer considers implicit function declarations as warnings (as seems to have been the case at least prior to the latext Xcode v13) but it turns them into errors.

Adding -Wno-implicit-function-declaration to the CFLAGS list here so that it becomes:

override CFLAGS += -c -g -p -pg -Wimplicit -I./ -I./nicksrc -Wno-implicit-function-declaration

Fixed this particular error.

This is really an emergency solution, but one that works without modifying the source code. Explicitly including #include <math.h> in appropriate places should be the way to go, but I have not tested that myself.

Maybe it's worth implementing it in the Makefile? Unlike the usual openblas or gsl compilation errors, which are easy even for non-C/C++ programmers to solve with a bits of googling, this one took me a bit to get around.


Description of the problem # 2

Also, for completeness, it seems that the location of Homebrew-installed libraries suggested in the Makefiles under src/ is different in the latest version of Homebrew and/or macOS Monterey, the paths suggested here no longer work. Because of this, even uncommenting the Mac-specific flags doesn't work, and the compiler complains about the missing GSL.

Solution to the problem # 2

I had to change these flags to these locations:

override CFLAGS += -I/opt/homebrew/opt/openblas/include -I/opt/homebrew/opt/gsl/include
override LDFLAGS += -L/opt/homebrew/opt/openblas/lib -L/opt/homebrew/opt/gsl/lib

Obviously this will depend on the version of Homebrew and possibly also macOS so I'm not sure if it's worth modifying the Makefile (maybe it is, because this is the current status of things in the Homebrew world). However, I think the issue #1 with implicit function declarations is backwards compatible as well as necessary in latest Xcode, so it would be great to have it implemented in future versions.

With both of these fixes in place, I was able to compile ADMIXTOOLS on the latest M1 MBP macOS without further problems, using the default Makefile.


Hope this helps (even if only for people googling for similar errors, in ADMIXTOOLS or elsewhere).

--Martin

@bodkan
Copy link
Author

bodkan commented Apr 22, 2022

On a less important note, I have also noticed that the testing Perl script mklog has a hardcoded path to the Perl interpreter. I would suggest changing this to #!/usr/bin/env perl -w which should make it much more platform independent. (At least on my Macs, the default built-in Perl interpreter binary is in a different location to the one given in the mklog hashbang line).

@avleon
Copy link

avleon commented Nov 15, 2024

Hi, I'm trying to install admixtools on Mac but I keep getting an error when I run make install. I added the flags so the linker can find the definitions for gsl and openblas but when I tried to do brew install argp it says

Warning: No available formula with the name "argp". Did you mean argo or argc?

I installed argp-standalone and added the flag for /include and /lib but I keep getting the following error message:

Undefined symbols for architecture x86_64:
  "_argp_parse", referenced from:
      _main in transpose.o
  "_argp_usage", referenced from:
      _parse_opt in transpose.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [transpose] Error 1

I then installed argparse and I noticed the /lib directory only has two directories inside (/cmake and /pkgconfig) and there is no file with .a extension. Not sure if I need that file but the other program have those files. Any idea how to fix this error?

Thanks!


UPDATE: I FIGURED OUT THE PROBLEM!!!!!!

I just needed to add the -largp flag to the Makefile in the first line (shown below)

override LDLIBS += -lgsl -largp -lopenblas -lm -lnick

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

2 participants