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

zarith and conf-gmp need to be smarter on macos x #3000

Closed
avsm opened this issue Nov 3, 2014 · 11 comments
Closed

zarith and conf-gmp need to be smarter on macos x #3000

avsm opened this issue Nov 3, 2014 · 11 comments
Labels

Comments

@avsm
Copy link
Member

avsm commented Nov 3, 2014

gmp.h is in /usr/local/include but there's no pkg-config. So to compile zarith on MacOS X I need to:

LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include opam install zarith -v

I suspect we need to pkg-config up gmp to make this opam-friendly

@avsm
Copy link
Member Author

avsm commented Nov 3, 2014

and also zmq.h. has something changed on yosemite i wonder...

# 
# /Users/avsm/.opam/4.01.0/bin/ocamlopt.opt unix.cmxa -I /Users/avsm/.opam/4.01.0/lib/ocaml/ocamlbuild /Users/avsm/.opam/4.01.0/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /Users/avsm/.opam/4.01.0/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# /Users/avsm/.opam/4.01.0/bin/ocamlfind ocamlc -ccopt -I -ccopt /Users/avsm/.opam/4.01.0/lib/uint -ccopt -Wall -ccopt -Wextra -ccopt -O2 -c src/caml_zmq_stubs.c
# + /Users/avsm/.opam/4.01.0/bin/ocamlfind ocamlc -ccopt -I -ccopt /Users/avsm/.opam/4.01.0/lib/uint -ccopt -Wall -ccopt -Wextra -ccopt -O2 -c src/caml_zmq_stubs.c
# src/caml_zmq_stubs.c:30:10: fatal error: 'zmq.h' file not found
# #include <zmq.h>
#          ^
# 1 error generated.
# Command exited with code 2.
### stderr ###

@amirmc
Copy link
Member

amirmc commented Aug 12, 2015

I just hit this issue again on a fresh switch (and came back here for the appropriate incantation). How do we fix this?

@aluuu
Copy link
Contributor

aluuu commented Oct 21, 2015

Ran into this issue during following Mirage tutorial screencast.
Defining LDFLAGS and CFLAGS worked for me.

@MagnusS
Copy link
Contributor

MagnusS commented Nov 10, 2015

It's not possible to override CFLAGS and LDFLAGS on OS X anymore, as they are now set to /usr/local/* in opam. If homebrew/gmp.h is installed in a different location than /usr/local installation fails.

@jbulow
Copy link

jbulow commented Jul 3, 2016

Macports installs gmp.h in /opt/local/include. Does this mean that opam is broken on OSX and it will not be fixed?

@francesco-zappa-nardelli
Copy link

francesco-zappa-nardelli commented Jan 22, 2017

Dear all, I have encountered the same problem of jbulow:

Macports installs gmp.h in /opt/local/include. Does this mean that opam is broken on OSX and it will not be fixed?

This is a showstopper for me. Is there any workaround? (Using brew instead of macport is not something I consider a workaround). Can it / will it be fixed? Thanks.

-francesco

@jbulow
Copy link

jbulow commented Feb 15, 2017

Still broken in opam2-beta

@psilord
Copy link

psilord commented Feb 16, 2017

I have run into the same problem as jbulow as well, any suggestions on a decent workaround to tell opam that /opt/local and /usr/local can both exist at the same time? Thank you!

dbuenzli added a commit to dbuenzli/opam-repository that referenced this issue Jul 4, 2017
In particular this allows to use again LDFLAGS and CFLAGS
environment variables to choose your location and and automatically
checks for the two locations where gmp will be found in 99% of
the cases.

Closes ocaml#3000 and ocaml#9389.
@dbuenzli
Copy link
Contributor

dbuenzli commented Jul 4, 2017

So basically on macOS by checking two locations it seems that we catch 99% of the install base of gmp.

So in #9728 I simply move to the solution of checking both locations. If I got my shell quoting right I also reinstated the ability @MagnusS mentioned was lost to explicitely specify LDFLAGS and and CFLAGS.

This may not be the best solution but it should work reasonably well for the time being.

The problem should be revisited in opam v2 when packages will be able to set environment variables (and thus extend PKG_CONFIG_PATH) by having simple conf-* packages that create and install .pc file according to where C packages that lack one are discovered.

Using such a custom .pc packages for gmp will allow to use pkg-config in zarith build instructions.

dbuenzli added a commit to dbuenzli/opam-repository that referenced this issue Jul 4, 2017
In particular this allows to use again LDFLAGS and CFLAGS
environment variables to choose your location and and automatically
checks for the two locations where gmp will be found in 99% of
the cases.

Closes ocaml#3000 and ocaml#9389.
dbuenzli added a commit to dbuenzli/opam-repository that referenced this issue Jul 4, 2017
In particular this allows to use again LDFLAGS and CFLAGS
environment variables to choose your location and and automatically
checks for the two locations where gmp will be found in 99% of
the cases.

Closes ocaml#3000 and ocaml#9389.
dbuenzli added a commit to dbuenzli/opam-repository that referenced this issue Jul 4, 2017
In particular this allows to use again LDFLAGS and CFLAGS
environment variables to choose your location and and automatically
checks for the two locations where gmp will be found in 99% of
the cases.

Closes ocaml#3000 and ocaml#9389.
dbuenzli added a commit to dbuenzli/opam-repository that referenced this issue Jul 7, 2017
In particular this allows to use again LDFLAGS and CFLAGS
environment variables to choose your location and and automatically
checks for the two locations where gmp will be found in 99% of
the cases.

Closes ocaml#3000 and ocaml#9389.
@jberdine
Copy link
Contributor

I just want to note that I ran into a minor issue caused by this fix. As part of debugging some linker trouble, a ld: warning: directory not found for option '-L/opt/local/lib' warning sent me on a bit of a wild goose chase, only to find that it is a spuriously added option by the zarith opam file.

It would be an improvement to add only the directive to the needed path, although I don't know how to reliably achieve that.

@mimoo
Copy link
Contributor

mimoo commented Sep 27, 2022

I still get these messages btw

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

No branches or pull requests