Hello, I am experiencing the same bug in Ubuntu 20.04 (Focal). My binfmtc version is 0.17-2 and versions of gcc and g++ are : gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0 g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0. Here is output from running realcsh.c :
realcsh.c: In function ‘main’: realcsh.c:96:7: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result] 96 | asprintf(&tempfilename, "%s/realcshXXXXXX", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 97 | getenv("BINFMTCTMPDIR")?: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 98 | getenv("TMPDIR")?: | ~~~~~~~~~~~~~~~~~~ 99 | getenv("TEMPDIR")?: | ~~~~~~~~~~~~~~~~~~~ 100 | "/tmp" | ~~~~~~ 101 | ); | ~ realcsh.c:126:7: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result] 126 | system (tempfilename); | ^~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccRfBXnK.o: in function `main': /usr/bin/realcsh.c:64: undefined reference to `readline' /usr/bin/ld: /usr/bin/realcsh.c:72: undefined reference to `add_history' collect2: error: ld returned 1 exit status binfmtc: Compilation failed for /usr/bin/realcsh.c, see above messages for details Possible fix : If I set the variable BINFMTC_DEBUG to 1 by export BINFMTC_DEBUG=1 I can see that binfmtc-interpreter executes : binfmtc: Execute command-line: gcc -o /tmp/binfmtc0biaup -x c - lreadline -I/usr/include/readline -O2 -Wall -g "realcsh.c" This is not right and does not compile if I run the same command on the terminal (with "realcsh.c" replaced by "/usr/bin/realcsh.c") and also produces exactly the same error message as running realcsh.c (without BINFMTC_DEBUG). The proper order of gcc options, which compiles, is : gcc -x c -O2 -Wall -g -I/usr/include/readline "/usr/bin/realcsh.c" -lreadline -o /tmp/binfmtc0biaup The -lreadline option should be before -o in order for the linking to work.