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

Building on Mac Fails #3

Closed
classicjazz opened this issue Aug 9, 2019 · 21 comments
Closed

Building on Mac Fails #3

classicjazz opened this issue Aug 9, 2019 · 21 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@classicjazz
Copy link

classicjazz commented Aug 9, 2019

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

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 <ebur128.h>
^~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/loudgain.dir/src/loudgain.c.o] Error 1
make[1]: *** [CMakeFiles/loudgain.dir/all] Error 2

@Moonbase59
Copy link
Owner

Moonbase59 commented Aug 10, 2019

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 Moonbase59 added documentation Improvements or additions to documentation good first issue Good for newcomers labels Aug 10, 2019
@Moonbase59
Copy link
Owner

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

Moonbase59 commented Aug 10, 2019

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

  • homebrew will auto-install dependencies when they are in the formula.
  • homebrew will also apparently install the program's development header (.h) files when installing something.

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) …

  • FFmpeg version should be >= 3.4.6 (loudgain -v should show at least libswresample 2.9.100)
  • libtag (or libtag1) should be >= 1.11.1, best compiled from GitHub because some bugs have been fixed but no new version came out since
  • libebur128 should be >= 1.2.4 because of a bug in older versions

Let me know if this works out.

@Moonbase59
Copy link
Owner

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

@classicjazz
Copy link
Author

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

Moonbase59 commented Aug 10, 2019

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

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

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

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

@classicjazz
Copy link
Author

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

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

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

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

Moonbase59 commented Aug 10, 2019

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 Moonbase59 added enhancement New feature or request and removed documentation Improvements or additions to documentation labels Aug 10, 2019
@Moonbase59
Copy link
Owner

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

@classicjazz
Copy link
Author

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

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

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

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

grr commented Apr 14, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants