Moonbase59 / loudgain

ReplayGain 2.0 loudness normalizer based on the EBU R128/ITU BS.1770 standard (-18 LUFS, FLAC, Ogg, MP2, MP3, MP4, M4A, AAC, ALAC, Opus, ASF, WMA, WAV, AIFF, WavPack, APE)
Other
182 stars 23 forks source link

Building on Mac Fails #3

Closed classicjazz closed 4 years ago

classicjazz commented 4 years ago

Manual building on Mac fails at the $ cmake .. command.

$ cmake ..

-- The C compiler identification is AppleClang 10.0.1.10010046 -- The CXX compiler identification is AppleClang 10.0.1.10010046 -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2") -- Checking for module 'libavcodec' -- Found libavcodec, version 58.55.100 -- Checking for module 'libavformat' -- Found libavformat, version 58.30.100 -- Checking for module 'libswresample' -- Found libswresample, version 3.6.100 -- Checking for module 'libavutil' -- Found libavutil, version 56.33.100 -- Checking for module 'taglib' -- No package 'taglib' found CMake Error at /usr/local/Cellar/cmake/3.15.1/share/cmake/Modules/FindPkgConfig.cmake:458 (message): A required package was not found Call Stack (most recent call first): /usr/local/Cellar/cmake/3.15.1/share/cmake/Modules/FindPkgConfig.cmake:637 (_pkg_check_modules_internal) CMakeLists.txt:25 (PKG_CHECK_MODULES)

And the logfile is attached. CMakeOutput.log

classicjazz commented 4 years ago

So based on the errors above, I ran "homebrew install libtag". And this resulted in Pouring taglib-1.11.1.mojave.bottle.tar.gz.

Running cmake again:

cmake .. -- Checking for module 'taglib' -- Found taglib, version 1.11.1 -- Configuring done -- Generating done -- Build files have been written to: /Users/mike/loudgain/build

But then running make results in the following error:

make [ 20%] Building C object CMakeFiles/loudgain.dir/src/loudgain.c.o /Users/mike/loudgain/src/loudgain.c:70:10: fatal error: 'ebur128.h' file not found

include

     ^~~~~~~~~~~

1 error generated. make[2]: [CMakeFiles/loudgain.dir/src/loudgain.c.o] Error 1 make[1]: [CMakeFiles/loudgain.dir/all] Error 2

Moonbase59 commented 4 years ago

Thanks for your continuous feedback, appreciate it, since I don’t have access to a Mac and there seem no VMs about. :-(

Good work on "taglib"!

You also need the development headers for libebur128, maybe this library can be installed with homebrew, too? There is a formula in homebrew-core.

Hint: I saw in the formula that it has a dependency on "speex". If homebrew does not resolve that, you might also have to install speex before you can brew libebur128.

Taglib 1.11.1 and libebur128 1.2.4 are good versions to work with.

I much hope you get it going and we can somehow pusblish an easy "recipe" for Mac—would be a great relief for other Mac users, too!

Moonbase59 commented 4 years ago

If homebrew can resolve dependencies automatically, you could probably simply add something like this in your loudgain formula:

  depends_on "cmake" => :build
  depends_on "pkg-config" => :build
  depends_on "libtag" => :build
  depends_on "libebur128" => :build

Another question: Does homebrew always include the development headers when installing something and do you by chance have ffmpeg installed?

That’s because I tried to keep loudgain as versatile as possible while having as few dependencies as possibe (really only cmake, pkg-config for building, and libtag, libebur128 and some of the FFmpeg libraries for running).

Moonbase59 commented 4 years ago

Just talked to a very helpful person on the #machomebrew IRC channel. He tells me the following:

This could mean if you add

  depends_on "cmake" => :build
  depends_on "pkg-config" => :build
  depends_on "ffmpeg"
  depends_on "libtag"
  depends_on "libebur128"

in your loudgain formula, we should get all the header files needed for compilation and all libraries needed to run loudgain.

For best results (i.e., least upstream bugs) …

Let me know if this works out.

Moonbase59 commented 4 years ago

You also probably found a bug, congratulations! :-)

classicjazz commented 4 years ago

Yes, I am running MPV head and FFMPEG head. I can uninstall if needed for testing.

Manually installing via brew the following, shows:

libebur128 1.2.4 is already installed and up-to-date taglib 1.11.1 is already installed and up-to-date

I am getting closer but still errors...

brew install --HEAD https://raw.githubusercontent.com/classicjazz/loudgain/master/loudgain.rb

==> Cloning https://github.com/Moonbase59/loudgain.git Updating /Users/mike/Library/Caches/Homebrew/loudgain--git ==> Checking out branch master Already on 'master' Your branch is up to date with 'origin/master'. HEAD is now at 807c4d3 Make sometimes didn't find ebur128.h, see #3 ==> cmake . -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/loudgain/HEAD-807c4d3 -DCMAK Last 15 lines from /Users/mike/Library/Logs/Homebrew/loudgain/01.cmake: 2019-08-10 09:57:04 -0400

cmake . -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/loudgain/HEAD-807c4d3 -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev

CMake Error: The source directory "/tmp/loudgain-20190810-39025-1n12awq/build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.

Moonbase59 commented 4 years ago

Hmm. Looks like it tries to "cmake ." instead of "mkdir build && cd build" → "cmake .." like in manual compilation. Wonder how that can be fixed.

Is there something like a "pre-build" step in homebrew formulae that could be used to create the build dir and change into it?

Maybe more like:

def install
  mkdir "build" do
    system "cmake", "-G", "Unix Makefiles", "..", *std_cmake_args
    system "make"
    system "make", "install"
  end
end
Moonbase59 commented 4 years ago

Coming back to "manual install": Now that libebur128, taglib and a recent FFmpeg are installed, you might again try the original build instructions at
https://github.com/Moonbase59/loudgain#building

classicjazz commented 4 years ago

naples:build mike$ cmake .. -- The C compiler identification is AppleClang 10.0.1.10010046 -- The CXX compiler identification is AppleClang 10.0.1.10010046 -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2") -- Checking for module 'libavcodec' -- No package 'libavcodec' found CMake Error at /usr/local/Cellar/cmake/3.15.2/share/cmake/Modules/FindPkgConfig.cmake:458 (message): A required package was not found Call Stack (most recent call first): /usr/local/Cellar/cmake/3.15.2/share/cmake/Modules/FindPkgConfig.cmake:637 (_pkg_check_modules_internal) CMakeLists.txt:21 (PKG_CHECK_MODULES)

-- Configuring incomplete, errors occurred! See also "/Users/mike/loudgain/build/CMakeFiles/CMakeOutput.log". naples:build mike$ make make: *** No targets specified and no makefile found. Stop. naples:build mike$

Moonbase59 commented 4 years ago

Please try commit 97cbaab. I try to use instead which should have the needed stuff on Mac OS X.

classicjazz commented 4 years ago

naples:~ mike$ git clone https://github.com/Moonbase59/loudgain.git Cloning into 'loudgain'... remote: Enumerating objects: 61, done. remote: Counting objects: 100% (61/61), done. remote: Compressing objects: 100% (30/30), done. remote: Total 495 (delta 33), reused 50 (delta 29), pack-reused 434 Receiving objects: 100% (495/495), 482.58 MiB | 35.55 MiB/s, done. Resolving deltas: 100% (275/275), done. naples:~ mike$ cd loudgain naples:loudgain mike$ mkdir build && cd build naples:build mike$ cmake .. -- The C compiler identification is AppleClang 10.0.1.10010046 -- The CXX compiler identification is AppleClang 10.0.1.10010046 -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2") -- Checking for module 'libavcodec' -- Found libavcodec, version 58.55.100 -- Checking for module 'libavformat' -- Found libavformat, version 58.30.100 -- Checking for module 'libswresample' -- Found libswresample, version 3.6.100 -- Checking for module 'libavutil' -- Found libavutil, version 56.33.100 -- Checking for module 'taglib' -- Found taglib, version 1.11.1 -- Looking for include file pty.h -- Looking for include file pty.h - not found -- Configuring done -- Generating done -- Build files have been written to: /Users/mike/loudgain/build naples:build mike$ make Scanning dependencies of target loudgain [ 20%] Building C object CMakeFiles/loudgain.dir/src/loudgain.c.o [ 40%] Building C object CMakeFiles/loudgain.dir/src/printf.c.o In file included from /Users/mike/loudgain/src/printf.c:45: /Users/mike/loudgain/src/util.h:53:14: warning: implicit declaration of function 'sysf_printf' is invalid in C99 [-Wimplicit-function-declaration] if (rc < 0) sysf_printf("close()"); ^ In file included from /Users/mike/loudgain/src/printf.c:48: /Users/mike/loudgain/src/printf.h:48:13: error: conflicting types for 'sysf_printf' extern void sysf_printf(const char fmt, ...); ^ /Users/mike/loudgain/src/util.h:53:14: note: previous implicit declaration is here if (rc < 0) sysf_printf("close()"); ^ In file included from /Users/mike/loudgain/src/printf.c:49: /Users/mike/loudgain/src/util.h:37:20: error: redefinition of 'freep' static inline void freep(void p) { ^ /Users/mike/loudgain/src/util.h:37:20: note: previous definition is here static inline void freep(void p) { ^ In file included from /Users/mike/loudgain/src/printf.c:49: /Users/mike/loudgain/src/util.h:46:20: error: redefinition of 'closep' static inline void closep(int p) { ^ /Users/mike/loudgain/src/util.h:46:20: note: previous definition is here static inline void closep(int *p) { ^ /Users/mike/loudgain/src/printf.c:178:17: error: variable has incomplete type 'struct winsize' struct winsize ws; ^ /Users/mike/loudgain/src/printf.c:178:9: note: forward declaration of 'struct winsize' struct winsize ws; ^ /Users/mike/loudgain/src/printf.c:180:6: warning: implicit declaration of function 'ioctl' is invalid in C99 [-Wimplicit-function-declaration] if (ioctl(fd, TIOCGWINSZ, &ws) < 0 || !ws.ws_row || !ws.ws_col) ^ /Users/mike/loudgain/src/printf.c:180:16: error: use of undeclared identifier 'TIOCGWINSZ' if (ioctl(fd, TIOCGWINSZ, &ws) < 0 || !ws.ws_row || !ws.ws_col) ^ 2 warnings and 5 errors generated. make[2]: [CMakeFiles/loudgain.dir/src/printf.c.o] Error 1 make[1]: [CMakeFiles/loudgain.dir/all] Error 2 make: *** [all] Error 2

Moonbase59 commented 4 years ago

Trying MacOS turns out to be a Pandora’s Box … thanks for testing! You might want to test f8e2a7e in the meantime while I’m looking up how MacOS handles all these ioctl() things …

classicjazz commented 4 years ago

naples:~ mike$ git clone https://github.com/Moonbase59/loudgain.git Cloning into 'loudgain'... remote: Enumerating objects: 65, done. remote: Counting objects: 100% (65/65), done. remote: Compressing objects: 100% (33/33), done. remote: Total 499 (delta 35), reused 53 (delta 30), pack-reused 434 Receiving objects: 100% (499/499), 482.58 MiB | 40.51 MiB/s, done. Resolving deltas: 100% (277/277), done. naples:~ mike$ cd loudgain naples:loudgain mike$ mkdir build && cd build naples:build mike$ cmake .. -- The C compiler identification is AppleClang 10.0.1.10010046 -- The CXX compiler identification is AppleClang 10.0.1.10010046 -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2") -- Checking for module 'libavcodec' -- Found libavcodec, version 58.55.100 -- Checking for module 'libavformat' -- Found libavformat, version 58.30.100 -- Checking for module 'libswresample' -- Found libswresample, version 3.6.100 -- Checking for module 'libavutil' -- Found libavutil, version 56.33.100 -- Checking for module 'taglib' -- Found taglib, version 1.11.1 -- Looking for include file pty.h -- Looking for include file pty.h - not found -- Configuring done -- Generating done -- Build files have been written to: /Users/mike/loudgain/build naples:build mike$ make Scanning dependencies of target loudgain [ 20%] Building C object CMakeFiles/loudgain.dir/src/loudgain.c.o [ 40%] Building C object CMakeFiles/loudgain.dir/src/printf.c.o In file included from /Users/mike/loudgain/src/printf.c:49: /Users/mike/loudgain/src/util.h:38:20: error: redefinition of 'freep' static inline void freep(void p) { ^ /Users/mike/loudgain/src/util.h:38:20: note: previous definition is here static inline void freep(void p) { ^ In file included from /Users/mike/loudgain/src/printf.c:49: /Users/mike/loudgain/src/util.h:47:20: error: redefinition of 'closep' static inline void closep(int p) { ^ /Users/mike/loudgain/src/util.h:47:20: note: previous definition is here static inline void closep(int p) { ^ /Users/mike/loudgain/src/printf.c:178:17: error: variable has incomplete type 'struct winsize' struct winsize ws; ^ /Users/mike/loudgain/src/printf.c:178:9: note: forward declaration of 'struct winsize' struct winsize ws; ^ /Users/mike/loudgain/src/printf.c:180:6: warning: implicit declaration of function 'ioctl' is invalid in C99 [-Wimplicit-function-declaration] if (ioctl(fd, TIOCGWINSZ, &ws) < 0 || !ws.ws_row || !ws.ws_col) ^ /Users/mike/loudgain/src/printf.c:180:16: error: use of undeclared identifier 'TIOCGWINSZ' if (ioctl(fd, TIOCGWINSZ, &ws) < 0 || !ws.ws_row || !ws.ws_col) ^ 1 warning and 4 errors generated. make[2]: [CMakeFiles/loudgain.dir/src/printf.c.o] Error 1 make[1]: [CMakeFiles/loudgain.dir/all] Error 2 make: *** [all] Error 2

Moonbase59 commented 4 years ago

a92aefb removes the obsolete util.h. I'm still fighting with conditional #includes (either include pty.h on Linux or util.h on MacOS), any idea?

Moonbase59 commented 4 years ago

Wasn’t so obsolete, might want to try 259a920 … I neglected erasing the build folder between tries, please be sure you do so we start on a clean slate.

Moonbase59 commented 4 years ago

Any news? I’d much like to get a working and homebrew-installable MacOS version 0.5.4 out ;-)

classicjazz commented 4 years ago

For the manual build, it also errors out:

build mike$ sudo make install Password: [ 20%] Linking CXX executable loudgain ld: library not found for -lavcodec clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [loudgain] Error 1 make[1]: [CMakeFiles/loudgain.dir/all] Error 2 make: *** [all] Error 2

Moonbase59 commented 4 years ago

Seems like clang (?) doesn’t find the FFmpeg libraries in /usr/local/…. I’m sure they are there but maybe something Mac-specific is missing in CMakeLists.txt.

I had access to a 10.14.04 Mojave iMac today, for a few minutes, and interestingly enough, got it compiled and working using Homebrew, by using

brew install --HEAD libtag
brew install --HEAD Moonbase59/tap/loudgain

I wonder what brew does differently. Have you got any ideas (and are you actually a programmer)?

The formula used is here.

Moonbase59 commented 4 years ago

I‘ll release a version 0.5.4 tomorrow that‘ll build with Homebrew, but I suggest investigating further in a workable manual build and leave this issue open for the time being.

Moonbase59 commented 4 years ago

MacOS 10.14+ broke linking by using -isysroot which excludes /usr/local/lib. Fixed that in 0.5.4 in CMakeLists.txt. Manual compilation now works here (tested with Mojave 10.14.4).

grr commented 3 years ago

MacOS 10.14+ broke linking by using -isysroot which excludes /usr/local/lib. Fixed that in 0.5.4 in CMakeLists.txt. Manual compilation now works here (tested with Mojave 10.14.4).

/usr/local is the prefix used by homebrew, but the other popular packager on macOS is MacPorts, which uses /opt/local. Can this directory be added as well?