error: Failed to find library with shm_open
As shipped, anjuta 3.34.0 and 3.28.0 come with configure scripts generated by autoconf 2.69 which works fine. But sometimes users have a need to patch the configure.ac file or regenerate the configure script for other reasons, and the build of either version fails on macOS if the configure script is regenerated with autoconf 2.71:
checking for library containing shm_open... no
configure: error: Failed to find library with shm_open()
config.log says:
configure:25424: checking for library containing shm_open
configure:25454: ccache /usr/bin/clang++ -o conftest -pipe -Os -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64 -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64 conftest.cpp >&5
Undefined symbols for architecture x86_64:
"shm_open()", referenced from:
_main in conftest-fdd949.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:25454: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "Anjuta"
| #define PACKAGE_TARNAME "anjuta"
| #define PACKAGE_VERSION "3.34.0"
| #define PACKAGE_STRING "Anjuta 3.34.0"
| #define PACKAGE_BUGREPORT "http://bugzilla.gnome.org/enter_bug.cgi?product=anjuta"
| #define PACKAGE_URL "http://www.anjuta.org/"
| #define ANJUTA_MAJOR_VERSION 3
| #define ANJUTA_MINOR_VERSION 34
| #define ANJUTA_MICRO_VERSION 0
| #define ANJUTA_VERSION 3.34.0
| #define PACKAGE "anjuta"
| #define VERSION "3.34.0"
| #define YYTEXT_POINTER 1
| #define PREF_SUFFIX ""
| #define HAVE_STDIO_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_UNISTD_H 1
| #define STDC_HEADERS 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR ".libs/"
| #define HAVE_VTE_2_91 1
| #define HAVE_WEBKIT2 1
| #define HAVE_RENDER 1
| #define HAVE_CFPREFERENCESCOPYAPPVALUE 1
| #define HAVE_CFLOCALECOPYCURRENT 1
| #define HAVE_ICONV 1
| #define ENABLE_NLS 1
| #define HAVE_GETTEXT 1
| #define HAVE_DCGETTEXT 1
| #define GETTEXT_PACKAGE "anjuta"
| #define YYENABLE_NLS 1
| #define HAVE_DIRENT_H 1
| #define HAVE_FCNTL_H 1
| #define HAVE_FNMATCH_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_TIME_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_SYS_DIR_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_TIMES_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_UTIL_H 1
| #define HAVE_FNMATCH 1
| #define HAVE_STRSTR 1
| #define HAVE_GETLINE 1
| #define HAVE_DECL_LOCKF 1
| #define HAVE_LOCKF 1
| #define HAVE_FGETPOS 1
| #define HAVE_MKSTEMP 1
| #define TMPDIR "/tmp"
| /* end confdefs.h. */
|
| /* Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| char shm_open ();
| int
| main (void)
| {
| return shm_open ();
| ;
| return 0;
| }
configure:25454: ccache /usr/bin/clang++ -o conftest -pipe -Os -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64 -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64 conftest.cpp -lrt >&5
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The check for shm_open
was added in https://bugzilla.gnome.org/show_bug.cgi?id=704985. Presumably there was some behavior change in autoconf 2.70 or 2.71 that makes this fail where it used to work. The check is only needed for Linux, but is allowed to run on all operating systems, hence the problem now on macOS. Perhaps the simplest fix is to only run the test on Linux. If I remove that check, then build works fine.