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

fish 3.1.0 - build - fatal error: curses.h: No such file or directory #6600

Closed
chargrnv opened this issue Feb 13, 2020 · 4 comments · Fixed by #7219
Closed

fish 3.1.0 - build - fatal error: curses.h: No such file or directory #6600

chargrnv opened this issue Feb 13, 2020 · 4 comments · Fixed by #7219
Labels
Milestone

Comments

@chargrnv
Copy link

chargrnv commented Feb 13, 2020

fish: 3.1.0
cmake: 3.14.1
ncurses: 5.9

I have no local /usr installation of ncurses with development files. It is in a non-standard location.

If I set PKG_CONFIG_PATH to have the ncurses pkgconfig dir, ncurses is not found.
I also tried setting PATH so ncurses5-config could be found.

So I set

  -DCMAKE_SYSTEM_PREFIX_PATH="${UTILS_NCURSES};${UTILS_GETTEXT};${UTILS_READLINE}"

And then ncurses is found in the path that I expect.

However, it does not seem that the include path gets added to the build, I encounter this error when building:

/build/tmp/fish-3.1.0/src/builtin_set_color.cpp:8:20: fatal error: curses.h: No such file or directory

So additionally I am setting CFLAGS/CXXFLAGS

 -DCMAKE_C_FLAGS="-O2 -I${UTILS_NCURSES}/include" \
 -DCMAKE_CXX_FLAGS="-O2 -I${UTILS_NCURSES}/include" \

(the files here in "include" are links to "include/ncursesw" files)

In the end the build looks something like:

export PATH=${UTILS_CMAKE}/bin:$PATH

export CC=${UTILS_GCC}/bin/gcc
export CXX=${UTILS_GCC}/bin/g++

export LDFLAGS+=" -static-libgcc -static-libstdc++"
export LDFLAGS+=" -Wl,-rpath,${UTILS_NCURSES}/lib"

mkdir build && cd build
cmake \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_INSTALL_PREFIX=${PREFIX} \
 -DCMAKE_SYSTEM_PREFIX_PATH="${UTILS_NCURSES};${UTILS_GETTEXT};${UTILS_READLINE}" \
 -DCMAKE_C_FLAGS="-O2 -I${UTILS_NCURSES}/include" \
 -DCMAKE_CXX_FLAGS="-O2 -I${UTILS_NCURSES}/include" \
..

make -j${nproc}
make install

But ideally I would not have to set the CFLAGS/CXXFLAGS.

@zanchey
Copy link
Member

zanchey commented Feb 14, 2020

What operating system are you using?

I'd be interested in the output of cmake, in particular, if it displays the message "Falling back to pkg-config for (n)curses detection" - if not, that's why the pkg-config attempt doesn't work. Possibly the configure check should try pkgconfig first, though I'm not sure if that will work on systems that don't have it installed.

Setting the CMAKE_SYSTEM_PREFIX_PATH should do the job, so that might be worth investigating.

@zanchey zanchey added the cmake label Feb 14, 2020
@zanchey zanchey added this to the fish-future milestone Feb 14, 2020
@chargrnv
Copy link
Author

chargrnv commented Feb 14, 2020

I am running this in a CentOS 6 docker container.

This is the output when I run with pkg-config

export PKG_CONFIG_PATH=${UTILS_NCURSES}/lib/pkgconfig

mkdir build && cd build
cmake \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_INSTALL_PREFIX=${PREFIX} \
..
-- The C compiler identification is GNU 5.5.0
-- The CXX compiler identification is GNU 5.5.0
-- Check for working C compiler: /home/utils/gcc-5.5.0/bin/gcc
-- Check for working C compiler: /home/utils/gcc-5.5.0/bin/gcc -- 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: /home/utils/gcc-5.5.0/bin/g++
-- Check for working CXX compiler: /home/utils/gcc-5.5.0/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
Falling back to pkg-config for (n)curses detection
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.23")
-- Checking for one of the modules 'ncurses;curses'
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found

...

-- The following OPTIONAL packages have not been found:

 * Curses
 * BZip2
 * Readline
 * Editline

I do see this in CMakeCache.txt, so it looks like pkgconfig finds ncurses.

pkgcfg_lib_CURSES_ncurses:FILEPATH=/home/utils/ncurses-5.9-2/lib/libncurses.so

//Path to a library.
pkgcfg_lib_CURSES_tinfo:FILEPATH=/home/utils/ncurses-5.9-2/lib/libtinfo.so

@mqudsi
Copy link
Contributor

mqudsi commented Feb 28, 2020

I think the pkg fallback is possibly not properly distinguishing between ncurses and curses, and I'm guessing CentOS is one of those that don't symlink curses to ncurses.

@r-burns
Copy link
Contributor

r-burns commented Jul 22, 2020

I've been running into this myself. If I'm working on a server where I'm not an administrator, sometimes it's easiest to just build ncurses and fish-shell from source. #5466 might be related, not sure.

Repro Dockerfile:

FROM alpine:latest
ENV nthreads=8

# install prereqs
RUN apk update \
 && apk add git g++ make cmake

# build and install ncurses (to nonstandard prefix)
RUN wget ftp://ftp.invisible-island.net/ncurses/ncurses-6.2.tar.gz
RUN tar xf ncurses-6.2.tar.gz
RUN cd ncurses-6.2 \
 && ./configure --prefix=/ncurses-prefix \
 && make -j$nthreads install

# build fish
# (clone the fish-shell repo alongside this Dockerfile)
COPY fish-shell fish-shell
RUN cd fish-shell \
 && cmake . -DCMAKE_PREFIX_PATH=/ncurses-prefix \
 && make -j$nthreads install

The resulting error is

/fish-shell/src/builtin_set_color.cpp:12:10: fatal error: ncurses/curses.h: No such file or directory
   12 | #include <ncurses/curses.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.

@zanchey zanchey modified the milestones: fish-future, fish 3.2.0 Jul 25, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants