savonet / ocaml-lame

OCaml bindings to the LAME mp3 encoder.
http://liquidsoap.info/
GNU General Public License v2.0
4 stars 1 forks source link

"opam install lame" failing on MacOS #6

Open omarmn opened 1 year ago

omarmn commented 1 year ago

Trying to install liquidsoap on Mac as per instructions on the book. I am using opam to install it. All packages install fine expect lame. I am not a developer by trade, but I'm self taught and I do as much as I can. I am helping 2 community radios to automate their processes here using liquidsoap, and this is causing a major blocker for us. Any help would be much appreciated. I get the following error when installing lame using opam:

compiling c program:

 [...]
  |   return 0;
  | }
 run: cc -O2 -fno-strict-aliasing -fwrapv -pthread   -I /Users/omarnooreddin/.opam/5.0.0/lib/ocaml -o /var/folders/w2/mvkw17xs58vb9wdjzqz426_c0000gn/T/build_04116e_dune/ocaml-configurator0764f6/c-test-0/test.exe /var/folders/w2/mvkw17xs58vb9wdjzqz426_c0000gn/T/build_04116e_dune/ocaml-configurator0764f6/c-test-0/test.c -lm -lpthread -lmp3lame -lm
 -> process exited with code 1
 -> stdout:
 -> stderr:
  | /var/folders/w2/mvkw17xs58vb9wdjzqz426_c0000gn/T/build_04116e_dune/ocaml-configurator0764f6/c-test-0/test.c:2:10: fatal error: 'lame/lame.h' file not found
  | #include <lame/lame.h>
  |          ^~~~~~~~~~~~~
  | 1 error generated.
 Fatal error: exception File "src/config/discover.ml", line 23, characters 6-12: Assertion failed

For some reason, the "include" line is not finding the lame.h. I have installed lame using "brew", I can see it installed and lame.h file is there under the include folder in the LAME brew folders.

I am a little bit out of my depths here, but I tried editing the discover.ml file and I added an absolute path to the lame.h file to the include line, but that didn't work. I tried to copy the lame.h to the same place as discover.ml file, no luck here. I also tried another Mac (which is fresh out of the box) that had exactly the same problem.

Thanks :)

deanh commented 1 year ago

Maybe you want to use 4.13.1 instead of 5.0.0? I was able to get this to install under Rosetta with a new Mac (M2) after some playing around with it. Here's what I did:

Good luck!

deanh commented 1 year ago

The downside is that all OCaml/opam work should be done in Rosetta for this user or the .opam directory may become a mess–I didn't try to figure out how to maintain a separate arm64 install. This is fine for me, but could be a problem if you want to do any additional OCaml work.

blaisdellk commented 1 year ago

I'm not familiar with the toolchain so I can't explain all of the reasoning here, but I ran into the same issue using macports and was able to resolve so i'll add some ideas;

I successfully installed liquidsoap via opam on x86 macos with ocaml 5.1 using these extra steps

omarmn commented 11 months ago

Awesome thanks both. The project is currently on pause, shifted focus on other tasks. Once I get back to it, will report back :)

aerogus commented 9 months ago

Same problem here with MacOS on Apple M1 / Sonoma 14.2.1

% opam install lame
Constructing initial basis...
Number of 0-1 knapsack inequalities = 4639
Constructing conflict graph...
Conflict graph has 1165 + 413 = 1578 vertices
The following actions will be performed:
  βˆ— install lame 0.3.7

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
⬇ retrieved lame.0.3.7  (cached)
[ERROR] The compilation of lame.0.3.7 failed at "dune build -p lame -j 7 @install".

#=== ERROR while compiling lame.0.3.7 =========================================#
# context     2.1.5 | macos/arm64 | ocaml.5.1.1 | https://opam.ocaml.org#6d3d7021
# path        ~/.opam/default/.opam-switch/build/lame.0.3.7
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p lame -j 7 @install
# exit-code   1
# env-file    ~/.opam/log/lame-78701-7855f9.env
# output-file ~/.opam/log/lame-78701-7855f9.out
### output ###
# compiling c program:
# [...]
#  |   return 0;
#  | }
# run: cc -O2 -fno-strict-aliasing -fwrapv -pthread   -I /Users/lagune/.opam/default/lib/ocaml -o /var/folders/4g/rssv0wg15qxf3q3crvw2tdsr0000gn/T/build_a3cfa9_dune/ocaml-configurator194737/c-test-0/test.exe /var/folders/4g/rssv0wg15qxf3q3crvw2tdsr0000gn/T/build_a3cfa9_dune/ocaml-configurator194737/c-test-0/test.c -lpthread -lmp3lame -lm
# -> process exited with code 1
# -> stdout:
# -> stderr:
#  | /var/folders/4g/rssv0wg15qxf3q3crvw2tdsr0000gn/T/build_a3cfa9_dune/ocaml-configurator194737/c-test-0/test.c:2:10: fatal error: 'lame/lame.h' file not found
#  | #include <lame/lame.h>
#  |          ^~~~~~~~~~~~~
#  | 1 error generated.
# Fatal error: exception File "src/config/discover.ml", line 23, characters 6-12: Assertion failed

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
β”Œβ”€ The following actions failed
β”‚ Ξ» build lame 0.3.7
└─
╢─ No changes have been performed
# Run eval $(opam env) to update the current shell environment
aerogus commented 9 months ago

I finally managed to install lame with this command

% CPATH=/opt/homebrew/include LIBRARY_PATH=/opt/homebrew/lib opam install lame

Constructing initial basis...
Number of 0-1 knapsack inequalities = 194
Constructing conflict graph...
Conflict graph has 88 + 13 = 101 vertices
The following actions will be performed:
  βˆ— install lame 0.3.7

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
⬇ retrieved lame.0.3.7  (cached)
βˆ— installed lame.0.3.7
Done.

It was clearly written on the home page here : https://www.liquidsoap.info/doc-2.2.3/install.html :)

omarmn commented 8 months ago

Hi, I've restarted the project and once I set the PATHS as per above it worked for me too. I was following the instructions in the PDF, which didn't have those steps there. Thanks for pointing out this web page.