0

I am migrating a working application on a Raspberry Pi to the latest OS Bookworm.

On make, I get the following error:

make
clang++ -lpthread -L/usr/local/lib –lreadline -lcurl -lpigpio -o build/cpssuper build/common.cpp.o build/gpio.cpp.o build/mutex.cpp.o build/namedpipe.cpp.o build/console.cpp.o build/pcs-api-task.cpp.o build/main.cpp.o build/utils.cpp.o build/datetime.cpp.o
clang: error: no such file or directory: '–lreadline'
make: *** [Makefile:40: build/cpssuper] Error 1

I was previously using readline7 but this would not install, so I had to install readline8.

sudo apt-get install libreadline8 libreadline-dev

This installed successfully and if I run apt-cache I get the following:

apt-cache search readline
beef - flexible Brainfuck interpreter
bpython - fancy interface to the Python 3 interpreter
cdecl - Turn English phrases to C or C++ declarations
clisp - GNU CLISP, a Common Lisp implementation
cupt - flexible package manager -- console interface
fim - scriptable frame buffer, X.org and ascii art image viewer
golang-github-bettercap-readline-dev - Readline is a pure go implementation for a GNU-Readline like library
golang-github-chzyer-readline-dev - Readline is a pure go implementation for a GNU-Readline like library
golang-github-thomasrooney-gexpect-dev - pure golang expect library
golang-github-wader-readline-dev - Readline is a pure go(golang) implementation for GNU-Readline like library
golang-gopkg-readline.v1-dev - Pure Go implementation for GNU Readline-like library
ledit - line editor for interactive programs
lf - terminal file manager written in Go
libconfig-model-perl - module for describing and editing configuration data
libedit-dev - BSD editline and history libraries (development files)
libedit2 - BSD editline and history libraries
libeditline-dev - development files for libeditline
libeditline0 - line editing library similar to readline
libeditreadline-dev - BSD editline and history libraries (shim development files)
libenv-ps1-perl - prompt string formatter
libghc-readline-dev - Haskell bindings to GNU readline library
libghc-readline-doc - Haskell bindings to GNU readline library; documentation
libghc-readline-prof - Haskell bindings to GNU readline library; profiling libraries
libgnatcoll-readline20 - Ada binding for ReadLine input history (runtime)
libgnatcoll-readline21-dev - Ada binding for ReadLine input history (development)
libjline-java - Java library for handling console input
libjline-java-doc - Java library for handling console input - documentation
libjline2-java - console input handling in Java
libjline3-java - Console input handling library
libreadline-dev - GNU readline and history libraries, development files
libreadline-gplv2-dev - GNU readline and history libraries, development files
libreadline-java - GNU readline and BSD editline wrappers for Java
libreadline5 - GNU readline and history libraries, run-time libraries
libreadline5-dbg - GNU readline and history libraries, debugging libraries
libreadline6 - GNU readline and history libraries, run-time libraries
libreadline6-dbg - GNU readline and history libraries, debugging libraries
libreadline8 - GNU readline and history libraries, run-time libraries
libreply-perl - lightweight extensible Perl REPL
libruby3.0 - Libraries necessary to run Ruby 3.0
libruby3.1 - Libraries necessary to run Ruby 3.1
librust-rustyline-dev - Readline implementation based on Linenoise - Rust source code
libterm-readline-gnu-perl - Perl extension for the GNU ReadLine/History Library
libterm-readline-perl-perl - Perl implementation of Readline libraries
libterm-readline-ttytter-perl - Term::ReadLine driver with special features for microblogging
libterm-readline-zoid-perl - Pure Perl implementation of Readline libraries
libterm-shellui-perl - Perl module for fully-featured shell-like command line environment
libterm-ui-perl - Term::ReadLine UI made easy
libzed-ocaml - abstract engine for text edition in OCaml (runtime)
libzed-ocaml-dev - abstract engine for text edition in OCaml (development tools)
lua-readline - readline library for the Lua language
lua-readline-dev - readline development files for the Lua language
lua-torch-trepl - REPL Package for Torch Framework
microdc2 - command-line based Direct Connect client
ncftp - User-friendly and well-featured FTP client
node-getpass - get a password from terminal
node-keypress - Make any Node ReadableStream emit "keypress" events
node-read - Read user input from stdin module for Node.js
node-ws-iconv - A set of Node libraries for various filesystem-related functions
nwall - version of wall that uses GNU readline
perl6-readline - Readline binding for Perl 6
perlconsole - small program that lets you evaluate Perl code interactively
php-readline - readline module for PHP [default]
php8.2-readline - readline module for PHP
python3-mock-open - Better mock for file I/O
python3-prompt-toolkit - library for building interactive command lines (Python 3)
python3-readlike - GNU Readline-like line editing module
python3-urwid-readline - python-urwid textbox widget that supports readline shortcuts
raku-readline - Readline binding for Raku
readline-common - GNU readline and history libraries, common files
readline-doc - GNU readline and history libraries, documentation and examples
renameutils - Programs to make file renaming easier
rlfe - Front-end using readline to "cook" input lines for other programs
rlwrap - readline feature command line wrapper
sdcv - StarDict Console Version
swi-prolog - ISO/Edinburgh-style Prolog interpreter
swi-prolog-bdb - Berkeley DB interface for SWI-Prolog
swi-prolog-core - ISO/Edinburgh-style Prolog interpreter - core system
swi-prolog-core-packages - ISO/Edinburgh-style Prolog interpreter - core packages
swi-prolog-doc - documentation and examples for SWI-Prolog
swi-prolog-full - ISO/Edinburgh-style Prolog interpreter - full suit
swi-prolog-java - Bidirectional interface between SWI-Prolog and Java
swi-prolog-nox - ISO/Edinburgh-style Prolog interpreter - without X support
swi-prolog-odbc - ODBC library for SWI-Prolog
swi-prolog-test - tests and checks for SWI-Prolog
swi-prolog-x - User interface library for SWI-Prolog - with X support
tcl-tclreadline - GNU Readline Extension for Tcl/Tk
tintin++ - classic text-based MUD client
torch-trepl - REPL Wrapper Package for Torch Framework

My make file looks like this:

CC=clang
CXX=clang++
CPPFLAGS=-std=c++14 -Isrc/ -Wall -Wextra -Weffc++ -Wno-gnu-statement-expression -Wuninitialized -Wmissing-field-initializers #-Wsign-conversion
LDFLAGS = -lpthread -L/usr/local/lib –lreadline -lcurl -lpigpio
CFLAGS=

SRC_DIR ?= src
BUILD_DIR ?= build
DEP_DIR ?= .deps

TARGET ?= $(BUILD_DIR)/cpssuper

.PHONY: default all clean run

all: $(TARGET)

DEPFLAGS= -MT $@ -MMD -MP -MF $(DEP_DIR)/$*.Td

SRC_FILES := $(shell find $(SRC_DIR) -name *.cpp)
C_SRC_FILES := $(shell find $(SRC_DIR) -name *.c)
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.cpp.o, $(SRC_FILES))
C_OBJ_FILES := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.c.o, $(C_SRC_FILES))

POST_COMPILE = @mv -f $(DEP_DIR)/$*.Td $(DEP_DIR)/$*.d && touch $@

    
$(BUILD_DIR)/%.c.o: $(SRC_DIR)/%.c $(DEP_DIR)/%.d
    @mkdir -p $(@D)
    $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
    $(POST_COMPILE)
    
$(BUILD_DIR)/%.cpp.o: $(SRC_DIR)/%.cpp $(DEP_DIR)/%.d
    @mkdir -p $(@D)
    $(CXX) $(DEPFLAGS) $(CPPFLAGS) -c -o $@ $<
    $(POST_COMPILE)

$(TARGET): $(C_OBJ_FILES) $(OBJ_FILES)
    $(CXX) $(LDFLAGS) -o $@ $^

run: $(TARGET)
    ./$(TARGET)

clean:
    -rm $(OBJ_FILES)
    -rm $(C_OBJ_FILES)

$(DEP_DIR)/%.d:
    @mkdir -p $(@D)
.PRECIOUS: $(DEP_DIR)/%.d

include $(wildcard $(patsubst $(SRC_DIR)/%.cpp, $(DEP_DIR)/%.d, $(SRC_FILES)))
include $(wildcard $(patsubst $(SRC_DIR)/%.c, $(DEP_DIR)/%.d, $(C_SRC_FILES)))

Any help appreciated.

3
  • 1
    Make sure you're using a hyphen, not an emdash. Commented Oct 9, 2024 at 1:56
  • Thank you so much. How did you even see the difference? I can see it now that I know to look for it. I have never heard of an mdash and have no idea how to type one or how it got there. I didn't think I made any changes in the make file. Commented Oct 9, 2024 at 2:43
  • ADL, I've been bitten by this sort of thing before when cut'n'pasting from web pages, where they don't always accurately maintain the characters. Commented Oct 9, 2024 at 7:55

1 Answer 1

1

The question has already been answered in the comments, but just to put the info in the proper box:

The problem is that the Makefile contains an en dash, U+2013, instead of a hyphen, U+002D. Consequently, the entire –lreadline is treated as the name of an input file, which (unsurprisingly) is not found. These two characters are visually identical in many fixed-width fonts.

One way to check this is to pass that line through hexdump -C:

$ echo 'LDFLAGS = -lpthread -L/usr/local/lib –lreadline -lcurl -lpigpio' | hexdump -C
00000000  4c 44 46 4c 41 47 53 20  3d 20 2d 6c 70 74 68 72  |LDFLAGS = -lpthr|
00000010  65 61 64 20 2d 4c 2f 75  73 72 2f 6c 6f 63 61 6c  |ead -L/usr/local|
00000020  2f 6c 69 62 20 e2 80 93  6c 72 65 61 64 6c 69 6e  |/lib ...lreadlin|
00000030  65 20 2d 6c 63 75 72 6c  20 2d 6c 70 69 67 70 69  |e -lcurl -lpigpi|
00000040  6f 0a                                             |o.|
00000042

In the above, e2 80 93 is the UTF-8 encoding of U+2013.

I speculate that someone put an example on the web that had passed through a program like MS-Word that "helpfully" substitutes certain characters, and that was in turn copied into the Makefile.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.