dankamongmen / notcurses

blingful character graphics/TUI library. definitely not curses.
https://nick-black.com/dankwiki/index.php/Notcurses
Other
3.63k stars 115 forks source link

Build fails on macOS Sonoma (build instructions missing) #2802

Open mttkay opened 2 weeks ago

mttkay commented 2 weeks ago

Please include the following data:

3.0.11

Warp v0.2024.10.29.08.02.stable_02


Problems

notcurses does not build on macOS Sonoma 14.7 (using homebrew dependencies) and there are no build instructions provided in https://github.com/dankamongmen/notcurses/blob/9d8cc0d86c1daf18f30110bfdf8388aeb96ff637/INSTALL.md.

This might just be user error, considering that there are binaries available for macOS, and brew install notcurses installs a working notcurses-demo binary. But I hope we can use this issue to document the build process better.

See thread here: https://github.com/dankamongmen/notcurses/discussions/2801

Problem 1: required header files are not found

I installed build dependencies as follows:

brew install cmake package-cfg doctest pandoc

I also installed the main library package:

brew install notcurses

which I assumed would also provide any necessary transitive dependencies for a successful build.

mkdir build/
cd build
cmake ../

Fails with:

-- Requested multimedia engine: ffmpeg
-- Requested build mode: RelWithDebInfo
-- Checking for one of the modules 'tinfo>=6.1;ncursesw>=6.1'
CMake Error at /opt/homebrew/Cellar/cmake/3.31.0/share/cmake/Modules/FindPkgConfig.cmake:938 (message):
  None of the required 'tinfo>=6.1;ncursesw>=6.1' found
Call Stack (most recent call first):
  CMakeLists.txt:104 (pkg_search_module)

-- Looking for unigbrk.h
-- Looking for unigbrk.h - not found
CMake Error at CMakeLists.txt:170 (message):
  Couldn't find unigbrk.h from GNU libunistring

-- Configuring incomplete, errors occurred!

There are two issues here:

  None of the required 'tinfo>=6.1;ncursesw>=6.1' found

Although I have ncurses installed, this check always fails, and I have to comment it out.

The second problem is that it cannot locate header files for libunistring and libdeflate. I fixed this by adding:

set(CMAKE_REQUIRED_INCLUDES /opt/homebrew/include)

Is there a way to pass this through the environment instead? I tried a number of ways such as setting CFLAGS, CXXFLAGS but nothing worked.

Problem 2: Linking fails

With the workarounds above, ultimately the library compiles but then fails to link:

[ 11%] Building C object CMakeFiles/notcurses-core.dir/src/compat/compat.c.o
[ 11%] Linking C shared library libnotcurses-core.dylib
Undefined symbols for architecture arm64:
  "_cur_term", referenced from:
      _ncdirect_stop_minimal in direct.c.o
      _notcurses_core_init in notcurses.c.o
      _notcurses_stop in notcurses.c.o
      _interrogate_terminfo in termdesc.c.o
  "_curses_version", referenced from:
      _init_banner in banner.c.o
  "_del_curterm", referenced from:
      _ncdirect_stop_minimal in direct.c.o
      _notcurses_core_init in notcurses.c.o
      _notcurses_stop in notcurses.c.o
      _interrogate_terminfo in termdesc.c.o
  "_setupterm", referenced from:
      _interrogate_terminfo in termdesc.c.o
  "_termname", referenced from:
      _interrogate_terminfo in termdesc.c.o
  "_tigetflag", referenced from:
      _interrogate_terminfo in termdesc.c.o
      _interrogate_terminfo in termdesc.c.o
      _interrogate_terminfo in termdesc.c.o
  "_tigetnum", referenced from:
      _interrogate_terminfo in termdesc.c.o
      _interrogate_terminfo in termdesc.c.o
      _interrogate_terminfo in termdesc.c.o
      _build_supported_styles in termdesc.c.o
  "_tigetstr", referenced from:
      _prep_special_keys in in.c.o
      _prep_special_keys in in.c.o
      _init_terminfo_esc in termdesc.c.o
      _terminfostr in termdesc.c.o
  "_tiparm", referenced from:
      _init_banner in banner.c.o
      _init_banner in banner.c.o
      _init_banner in banner.c.o
      _init_banner in banner.c.o
      _ncdirect_cursor_up in direct.c.o
      _ncdirect_cursor_left in direct.c.o
      _ncdirect_cursor_right in direct.c.o
      ...
ld: symbol(s) not found for architecture arm64
cc: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libnotcurses-core.3.0.9.dylib] Error 1
make[1]: *** [CMakeFiles/notcurses-core.dir/all] Error 2
make: *** [all] Error 2
mttkay commented 2 weeks ago

I found an answer to one problem: the error about missing tinfo and ncursesw dependencies. Stumbled upon it in this pipeline run: https://github.com/dankamongmen/notcurses/actions/runs/11151924316/job/30996427665

One needs to set env PKG_CONFIG_PATH="/opt/homebrew/opt/ncurses/lib/pkgconfig" when running cmake.

Still haven't found solutions to the other 2 issues (Looking for unigbrk.h - not found and the linker error.)

mttkay commented 2 weeks ago

The linker error also disappears when setting PKG_CONFIG_PATH to included ncurses -- that leaves the problem with the missing libunistring header file. I think this is just because cmake is not aware of /opt/homebrew/include?