notcurses icon indicating copy to clipboard operation
notcurses copied to clipboard

Do you have a bash script for BSD to install C++ build tools and compile notcurses from a fresh bsd distro install?

Open alanthie opened this issue 1 year ago • 5 comments

In an apt (debian like) distro it goes this way:

function install_pkg() { status="$(dpkg-query -W --showformat='${db:Status-Status}' "$1" 2>&1)" if [ ! $? = 0 ] || [ ! "$status" = installed ] then sudo apt -y install $1 else echo "$1 is already installed" fi }

install_pkg g++ install_pkg build-essential install_pkg cmake install_pkg git

install_pkg libgmp-dev install_pkg ffmpeg

notcurses

install_pkg doctest-dev install_pkg libavdevice-dev install_pkg libdeflate-dev install_pkg libgpm-dev install_pkg libncurses-dev install_pkg libqrcodegen-dev install_pkg libswscale-dev install_pkg libunistring-dev install_pkg pandoc install_pkg pkg-config

git clone ...notcurses...

cmake .. make sudo make install

I have build notcurses on 20 distros, but can not make it work on any bsd distro It is not notcurses fault, I just dont know how to install the C++ tools correctly on BSD

Thanks https://github.com/alanthie/build_all

alanthie avatar Feb 20 '25 01:02 alanthie

notcurses has both a FreeBSD and OpenBSD Port, as far as i know (though both are somewhat out of date; i got my FreeBSD VM working again last week, and hope to rectify at least the former soon).

so i'm not quite sure what you're asking. are you running into some compilation failure?

dankamongmen avatar Feb 21 '25 06:02 dankamongmen

If you have your own FreeBSD VM, do you have the steps to install and make C++ (gcc) works and compile notcourses.

I am using gcc, but since FreeBSD does not maintain gcc anymore, I guess your are now compiling with CLang. I dont have the technical knowledge to make gcc works on FreeBSD and it seems very difficult according to various posts. I did not test if I can compile my C++ projects with clang including notcurses. I may try it for FreeBSD if required.

I am adding stuff to notcurses for my projects and I need to compile it from sources. So far I have 20 Linux distro working, but not BSD.

Thanks

alanthie avatar Feb 21 '25 08:02 alanthie

ahhhh so you want to know how to build with gcc on freebsd. can you show me what failure you're running into?

dankamongmen avatar Feb 21 '25 12:02 dankamongmen

I have deleted my FreeBSD vm, I will post when I re-installed it

alanthie avatar Feb 21 '25 15:02 alanthie

Maybe this helps, I can compile on FreeBSD without problem, my FreeBSD version:

uname -a

# FreeBSD th80 14.1-RELEASE-p5 FreeBSD 14.1-RELEASE-p5 GENERIC amd64

About the C/C++ compiler on FreeBSD:

On FreeBSD, you don't need to install any build-base/build-essential like packages (if you're coming from any Linux distro), as LLVM (clang/clang++) installed with the FreeBSD base system.

Starting with FreeBSD 10.X clang is installed as cc; the GNU compiler lang/gcc is available in the Ports Collection.

ls -lht /usr/bin/{cc,c++,clang,clang++}

# -r-xr-xr-x  6 root wheel  101M Nov 26 17:22 /usr/bin/c++*
# -r-xr-xr-x  6 root wheel  101M Nov 26 17:22 /usr/bin/cc*
# -r-xr-xr-x  6 root wheel  101M Nov 26 17:22 /usr/bin/clang*
# -r-xr-xr-x  6 root wheel  101M Nov 26 17:22 /usr/bin/clang++*

If you want to install a different version of llvm, it's super easy, just run pkg install llvmXX (XX is the version number)

How to compile notcurses

I appended the following debug output commands to the CMakeLists.txt (it doesnt't matter if you don't have):

# =============================================================================
# Debug log
# =============================================================================
message(">>> CMAKE_EXPORT_COMPILE_COMMANDS: ${CMAKE_EXPORT_COMPILE_COMMANDS}")
message(">>> CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(">>> CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(">>> CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message(">>> CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
message(">>> CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}")
message(">>> CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}")
message(">>> HEADER_FILES_INSTALL_DIR: ${HEADER_FILES_INSTALL_DIR}")
message(">>> CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(">>> SHELL: $ENV{SHELL}")

So, let's do it:

#
# Install command form `notcurses/INSTALL.md` under `### FreeBSD / DragonFly BSD` section
#
doas pkg install archivers/libdeflate devel/ncurses multimedia/ffmpeg graphics/qr-code-generator devel/libunistring


#
# My FreeBSD missing packages
#
doas pkg install doctest hs-pandoc cmake


#
# So, configure the `cmake`:
#
# You DON'T need the `-DCMAKE_INSTALL_PREFIX=~/my-installed/` flag, it just my personal preferred install location!!!
#
# rm -rf build && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=$HOME/my-installed/ ..
#
rm -rf build && mkdir build && cd build && cmake ..

Here is the cmake configure step output:

-- The C compiler identification is Clang 18.1.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is Clang 18.1.5
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Requested multimedia engine: ffmpeg
-- Requested build mode: RelWithDebInfo
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "2.3.0")
-- Checking for one of the modules 'tinfo>=6.1;ncursesw>=6.1'
-- Checking for module 'libavcodec>=57.0'
--   Found libavcodec, version 60.31.102
-- Checking for module 'libavdevice>=57.0'
--   Found libavdevice, version 60.3.100
-- Checking for module 'libavformat>=57.0'
--   Found libavformat, version 60.16.100
-- Checking for module 'libavutil>=56.0'
--   Found libavutil, version 58.29.100
-- Checking for module 'libswscale>=5.0'
--   Found libswscale, version 7.5.100
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Looking for unigbrk.h
-- Looking for unigbrk.h - found
-- Looking for libdeflate.h
-- Looking for libdeflate.h - found
-- The following OPTIONAL packages have been found:

 * FFMpeg

-- The following REQUIRED packages have been found:

 * PkgConfig
 * terminfo
 * Threads
 * doctest (required version >= 2.3.5)
 * libunistring
 * DEFLATE

-- Configuring done (0.8s)
-- Generating done (0.1s)
-- Build files have been written to: /home/wison/temp/notcurses/build

>>> CMAKE_EXPORT_COMPILE_COMMANDS:
>>> CMAKE_SYSTEM_NAME: FreeBSD
>>> CMAKE_BUILD_TYPE: RelWithDebInfo
>>> CMAKE_C_COMPILER: /usr/bin/cc
>>> CMAKE_C_FLAGS:
>>> CMAKE_C_FLAGS_DEBUG: -g -Og
>>> CMAKE_C_FLAGS_RELEASE: -O3 -DNDEBUG
>>> HEADER_FILES_INSTALL_DIR:
>>> CMAKE_INSTALL_PREFIX: /home/wison/my-installed
>>> SHELL: /usr/local/bin/fish

Finally, build and install:

make
make install

Run it

After the make install, here are all installed folders and files (for my case):

N  wison | /home/wison/my-installed   tree -L 2
# .
# ├── bin
# │   ├── ncls
# │   ├── ncneofetch
# │   ├── ncplayer
# │   ├── nctetris
# │   ├── notcurses-demo
# │   ├── notcurses-info
# │   ├── notcurses-input
# │   ├── notcurses-tester
# │   └── tfman
# ├── include
# │   ├── ncpp
# │   └── notcurses
# ├── lib
# │   ├── cmake
# │   ├── libnotcurses-core.a
# │   ├── libnotcurses-core.so -> libnotcurses-core.so.3
# │   ├── libnotcurses-core.so.3 -> libnotcurses-core.so.3.0.13
# │   ├── libnotcurses-core.so.3.0.13
# │   ├── libnotcurses-ffi.so -> libnotcurses-ffi.so.3
# │   ├── libnotcurses-ffi.so.3 -> libnotcurses-ffi.so.3.0.13
# │   ├── libnotcurses-ffi.so.3.0.13
# │   ├── libnotcurses.a
# │   ├── libnotcurses.so -> libnotcurses.so.3
# │   ├── libnotcurses.so.3 -> libnotcurses.so.3.0.13
# │   ├── libnotcurses.so.3.0.13
# │   ├── libnotcurses++.a
# │   ├── libnotcurses++.so -> libnotcurses++.so.3
# │   ├── libnotcurses++.so.3 -> libnotcurses++.so.3.0.13
# │   └── libnotcurses++.so.3.0.13
# ├── libdata
# │   └── pkgconfig
# └── share
#     ├── doc
#     ├── man
#     └── notcurses

Because I customized the install folder, that's why I use LD_LIBRARY_PATH=$HOME/my-installed/lib to let notcurses executable to know when to find the shared libraries:

LD_LIBRARY_PATH=$HOME/my-installed/lib notcurses-info

notcurses 3.0.13 on tmux 3.3a (FreeBSD 14.1-RELEASE-p5)
58 rows (36px) 237 cols (16px) 2088x3792 rgb+256 colors
FreeBSD Clang 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15a9eac9) (LE)
terminfo 6.5.20240427 libdeflate 1.22 GPM n/a
af+ ab+ sum- vpa+ hpa+ sgr0+ op+ fgop+ bgop+ bce+ rect-                         0.3.100
af+ ab+ sum- vpa+ hpa+ sgr0+ op+ fgop+ bgop+ bce+ rect-
bold+ ital+ struck+ ucurl- uline+ u7+ ccc+ rgb+ el+
utf8+ 2x1+ 2x2- 3x2- 4x2- ⠃⠗⠇+ img+ vid+ indn+ gpm- kbd-
no known default fg no known default bg pmouse-
no bitmap graphics detected                            🯁🯂🯃https://notcurses.com
 ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█⎧ 🬀🬁🬂🬃🬄🬅🬆🬇🬈🬊🬋🬌🬍🬎🬏🬐🬑🬒🬓▌🬔🬕🬖🬗🬘🬙🬚🬛🬜🬝⎫♠♥🯰🯱🯲🯳🯴🯵🯶🯷🯸🯹⅗⅘⅙⅚⅛⎧▕▏⎫┌╥─╥─╥┐🭩⎛⎞
╲╿╱ ◨◧ ◪◩ ◖◗ ⫷⫸ ⎩🬟🬠🬡🬢🬣🬤🬥🬦🬧▐🬨🬩🬪🬫🬬🬭🬮🬯🬰🬱🬲🬳🬴🬵🬶🬷🬸🬹🬺🬻█⎭♦♣¼½¾⅐⅑⅒⅓⅔⅕⅖⅜⅝⅞⅟↉⎪🮇▎⎪├╜╓╫╖╙┤🭫⎜⎟
╾╳╼ ◲◱ ◶◵ 🮣🮠 🮤🮥◜◝ ◿◺ 🮞🮟 ◢◣ ┌┐─ ┏┓━ ╭╮─ ╔╗═ 🭽🭾▁♟♜♞⩘▵△▹▷▿▽◃◁⭡⭣⭠⭢⭧⭩⭦⭨⎪🮈▍⎪├─╨╫╨─┤┇⎜⎟
╱╽╲ ◳◰ ◷◴ 🮡🮢 🮦🮧◟◞ ◹◸ 🮝🮜 ◥◤ └┘│ ┗┛┃ ╰╯│ ╚╝║ 🭼🭿🭵♝♛♚⩗▴⏶⯅▲▸⏵⯈▶▾⏷⯆▼◂⏴⯇◀⎪▐▌⎪╞═╤╬╤═╡┋⎜⎟
⎡⠀⠁⠈⠉⠂⠃⠊⠋⠐⠑⠘⠙⠒⠓⠚⠛⠄⠅⠌⠍⠆⠇⠎⠏⠔⠕⠜⠝⠖⠗⠞⠟⠠⠡⠨⠩⠢⠣⠪⠫⠰⠱⠸⠹⠲⠳⠺⠻⠤⠥⠬⠭⠦⠧⠮⠯⠴⠵⠼⠽⠶⠷⠾⠿⎤⎨🮉▋⎬╞╕╘╬╛╒╡┊⎜⎟
⎢⡀⡁⡈⡉⡂⡃⡊⡋⡐⡑⡘⡙⡒⡓⡚⡛⡄⡅⡌⡍⡆⡇⡎⡏⡔⡕⡜⡝⡖⡗⡞⡟⡠⡡⡨⡩⡢⡣⡪⡫⡰⡱⡸⡹⡲⡳⡺⡻⡤⡥⡬⡭⡦⡧⡮⡯⡴⡵⡼⡽⡶⡷⡾⡿⎥⎪🮊▊⎪└┴─╨─┴┘╏⎝⎠
⎢⢀⢁⢈⢉⢂⢃⢊⢋⢐⢑⢘⢙⢒⢓⢚⢛⢄⢅⢌⢍⢆⢇⢎⢏⢔⢕⢜⢝⢖⢗⢞⢟⢠⢡⢨⢩⢢⢣⢪⢫⢰⢱⢸⢹⢲⢳⢺⢻⢤⢥⢬⢭⢦⢧⢮⢯⢴⢵⢼⢽⢶⢷⢾⢿⎥⎪🮋▉⎪╭──╮⟬⟭╔╗≶≷
⎣⣀⣁⣈⣉⣂⣃⣊⣋⣐⣑⣘⣙⣒⣓⣚⣛⣄⣅⣌⣍⣆⣇⣎⣏⣔⣕⣜⣝⣖⣗⣞⣟⣠⣡⣨⣩⣢⣣⣪⣫⣰⣱⣸⣹⣲⣳⣺⣻⣤⣥⣬⣭⣦⣧⣮⣯⣴⣵⣼⣽⣶⣷⣾⣿⎦⎪██⎪│╭╮│╔═╝║⊆⊇
 ▔🭶🭷🭸🭹🭺🭻▁ 🭁🭌 🭂🭍 🭃🭎 🭄🭏 🭅🭐 🭆🭑 🭇🬼 🭈🬽 🭉🬾 🭊🬿 🭋🭀 ₀₁₂₃₄₅₆₇₈₉ ⎛ ▁▂▃▄▅▆▇█🭫⎞⎪🭨🭪⎪╰╯││║╔═╝⊴⊵
 ▏🭰🭱🭲🭳🭴🭵▕ 🭒🭝 🭓🭞 🭔🭟 🭕🭠 🭖🭡 🭧🭜 🭢🭗 🭣🭘 🭤🭙 🭥🭚 🭦🭛 ⁰¹²³⁴⁵⁶⁷⁸⁹ ⎝ ▔🮂🮃▀🮄🮅🮆█🭩⎠⎩🭪🭨⎭⧒⧑╰╯╚╝❨❩⟃⟄

17 renders, 3.16ms (166.00µs min, 185.59µs avg, 386.12µs max)
17 rasters, 1.44ms (76.33µs min, 84.42µs avg, 95.15µs max)
17 writes, 643.40µs (34.70µs min, 37.85µs avg, 74.44µs max)
7.06KiB (103B min, 425B avg, 3.31KiB max) 0 inputs Ghpa: 0
0 failed renders, 0 failed rasters, 0 refreshes, 0 input errors
RGB emits:elides: def 2:1316 fg 1:2477 bg 2:1174
Cell emits:elides: 2478:464814 (99.47%) 99.85% 99.96% 99.83%
Bmap emits:elides: 0:0 (0.00%) 0B (0.00%) SuM: 0 (0.00%)

wisonye avatar Mar 27 '25 06:03 wisonye