Reputation: 33
I have a project built with Bazel that uses ncurses
, which I am trying to migrate to bzlmod for Bazel 8.0.0 LTS. I am trying to use the ncurses
module from the Bazel Central Repository.
I have this minimal repro case for this here: https://github.com/davidzchen/bazel-ncurses-example
When I try to build the repository on Ubuntu 24.04.1 LTS (via WSL), I get an error stating that ncurses.h
is not found:
$ bazel build //foo:color --verbose_failures
INFO: Analyzed target //foo:color (0 packages loaded, 0 targets configured).
ERROR: /home/dzc/Projects/davidzchen/bazel-ncurses-example/foo/BUILD:3:11: Compiling foo/color.cc failed: (Exit 1): gcc failed: error executing CppCompile command (from target //foo:color)
(cd /home/dzc/.cache/bazel/_bazel_dzc/0eea61d75b5304f994b8af9040b68be8/sandbox/linux-sandbox/162/execroot/_main && \
exec env - \
PATH='/home/dzc/.bin:/home/dzc/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Users/david/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/david/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/david/.dotnet/tools:/home/dzc/go/bin:/usr/lib/go/bin:/home/dzc/.antigen/bundles/robbyrussell/oh-my-zsh/lib:/home/dzc/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/history-substring-search:/home/dzc/.antigen/bundles/zsh-users/zsh-syntax-highlighting:/home/dzc/.antigen/bundles/zsh-users/zsh-completions:/home/dzc/.antigen/bundles/zsh-users/zsh-autosuggestions' \
PWD=/proc/self/cwd \
/usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++17' -MD -MF bazel-out/k8-fastbuild/bin/foo/_objs/color/color.pic.d '-frandom-seed=bazel-out/k8-fastbuild/bin/foo/_objs/color/color.pic.o' -fPIC -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/ncurses+ -iquote bazel-out/k8-fastbuild/bin/external/ncurses+ -isystem external/ncurses+/include -isystem bazel-out/k8-fastbuild/bin/external/ncurses+/include -isystem external/ncurses+/ncurses -isystem bazel-out/k8-fastbuild/bin/external/ncurses+/ncurses '-std=c++20' -c foo/color.cc -o bazel-out/k8-fastbuild/bin/foo/_objs/color/color.pic.o -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"')
# Configuration: 333f6f4c7cf3276607d148778aaf5f43ecbd710ad44e62c36ff54f462d3b62af
# Execution platform: @@platforms//host:host
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
foo/color.cc:3:10: fatal error: ncurses.h: No such file or directory
3 | #include "ncurses.h"
| ^~~~~~~~~~~
compilation terminated.
Target //foo:color failed to build
INFO: Elapsed time: 0.525s, Critical Path: 0.12s
INFO: 10 processes: 9 internal, 1 linux-sandbox.
ERROR: Build did NOT complete successfully
I get the same error if I change #include "ncurses.h"
to #include <ncurses.h>
. What is odd is that find -L . -name "ncurses.h"
from the repository root does not return any results, while searching for a different file in the ncurses source tree, such as codes.c
, does return results:
$ find -L . -name "ncurses.h"
$ find -L . -name "codes.c"
./bazel-bin/external/ncurses+/ncurses/codes.c
./bazel-out/k8-fastbuild/bin/external/ncurses+/ncurses/codes.c
./bazel-bazel-ncurses-example/bazel-out/k8-fastbuild/bin/external/ncurses+/ncurses/codes.c
Ubuntu version info:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: noble
Does anyone know why this is occurring and how I can fix this? Thank you in advance.
Upvotes: 0
Views: 26
Reputation: 33
Thanks to @wep21 on GitHub, I have a fix for this:
In the deps
for cc_library
and cc_binary
targets, we need to include both "@ncurses//:ncurses_headers",
and @ncurses
. Also, files need to #include <curses.h>
instead of #include <ncurses.h>
. See this commit for more details.
Further, the functions refresh
and box
are not available (though I am not sure why), and these functions need to be replaced with calls to wrefresh
and wborder
. See this commit for more details.
Upvotes: 0