Page MenuHome GnuPG

GPGme 1.23.2 has Undefined symbols: "strcasecmp(char const*, char const*)" on Mac OS X 10.4.11, PPC Tiger
Open, NormalPublic

Description

Building the software with MacPorts leads to this error:

/bin/sh ../../../libtool --tag=CXX --mode=link /opt/local/bin/g++-mp-7 -std=c++11 -pipe -Os -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0 -arch ppc -no-undefined -version-info 26:1:20 -L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc -o libgpgmepp.la -rpath /opt/local/lib exception.lo context.lo key.lo trustitem.lo data.lo callbacks.lo eventloopinteractor.lo editinteractor.lo keylistresult.lo keygenerationresult.lo importresult.lo decryptionresult.lo verificationresult.lo signingresult.lo encryptionresult.lo engineinfo.lo gpgsetexpirytimeeditinteractor.lo gpgsetownertrusteditinteractor.lo gpgsignkeyeditinteractor.lo gpgadduserideditinteractor.lo gpggencardkeyinteractor.lo gpgaddexistingsubkeyeditinteractor.lo gpgrevokekeyeditinteractor.lo defaultassuantransaction.lo scdgetinfoassuantransaction.lo gpgagentgetinfoassuantransaction.lo statusconsumerassuantransaction.lo vfsmountresult.lo configuration.lo tofuinfo.lo swdbresult.lo util.lo context_vanilla.lo ../../../src/libgpgme.la -L/opt/local/lib -lassuan
libtool: link: /opt/local/bin/g++-mp-7 -dynamiclib -arch ppc -o .libs/libgpgmepp.6.dylib .libs/exception.o .libs/context.o .libs/key.o .libs/trustitem.o .libs/data.o .libs/callbacks.o .libs/eventloopinteractor.o .libs/editinteractor.o .libs/keylistresult.o .libs/keygenerationresult.o .libs/importresult.o .libs/decryptionresult.o .libs/verificationresult.o .libs/signingresult.o .libs/encryptionresult.o .libs/engineinfo.o .libs/gpgsetexpirytimeeditinteractor.o .libs/gpgsetownertrusteditinteractor.o .libs/gpgsignkeyeditinteractor.o .libs/gpgadduserideditinteractor.o .libs/gpggencardkeyinteractor.o .libs/gpgaddexistingsubkeyeditinteractor.o .libs/gpgrevokekeyeditinteractor.o .libs/defaultassuantransaction.o .libs/scdgetinfoassuantransaction.o .libs/gpgagentgetinfoassuantransaction.o .libs/statusconsumerassuantransaction.o .libs/vfsmountresult.o .libs/configuration.o .libs/tofuinfo.o .libs/swdbresult.o .libs/util.o .libs/context_vanilla.o -L/opt/local/lib ../../../src/.libs/libgpgme.dylib /opt/local/lib/libgpg-error.dylib /opt/local/lib/libassuan.dylib -Os -arch ppc -Wl,-headerpad_max_install_names -arch ppc -install_name /opt/local/lib/libgpgmepp.6.dylib -compatibility_version 27 -current_version 27.1 -Wl,-single_module
Undefined symbols:

"strcasecmp(char const*, char const*)", referenced from:
    GpgME::Key::isRoot() const in key.o
    GpgME::Key::mergeWith(GpgME::Key const&) in key.o

ld: symbol(s) not found
collect2: error: ld returned 1 exit status
make[4]: * [libgpgmepp.la] Error 1
make[4]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_devel_gpgme/gpgme/work/gpgme-1.23.2/lang/cpp/src'
make[3]:
* [all-recursive] Error 1

The file in question, gpgme-1.23.2/lang/cpp/src/key.cpp, was compiled this way:

/bin/sh ../../../libtool --tag=CXX --mode=compile /opt/local/bin/g++-mp-7 -std=c++11 -DHAVE_CONFIG_H -I. -I../../../conf -I../../../src -fvisibility=hidden -I/opt/local/include -I/opt/local/include -DBUILDING_GPGMEPP -Wsuggest-override -Wzero-as-null-pointer-constant -I/opt/local/include -pipe -Os -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0 -arch ppc -MT key.lo -MD -MP -MF .deps/key.Tpo -c -o key.lo key.cpp
libtool: compile: /opt/local/bin/g++-mp-7 -std=c++11 -DHAVE_CONFIG_H -I. -I../../../conf -I../../../src -fvisibility=hidden -I/opt/local/include -I/opt/local/include -DBUILDING_GPGMEPP -Wsuggest-override -Wzero-as-null-pointer-constant -I/opt/local/include -pipe -Os -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0 -arch ppc -MT key.lo -MD -MP -MF .deps/key.Tpo -c key.cpp -fno-common -DPIC -o .libs/key.o
libtool: compile: /opt/local/bin/g++-mp-7 -std=c++11 -DHAVE_CONFIG_H -I. -I../../../conf -I../../../src -fvisibility=hidden -I/opt/local/include -I/opt/local/include -DBUILDING_GPGMEPP -Wsuggest-override -Wzero-as-null-pointer-constant -I/opt/local/include -pipe -Os -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0 -arch ppc -MT key.lo -MD -MP -MF .deps/key.Tpo -c key.cpp -o key.o >/dev/null 2>&1
mv -f .deps/key.Tpo .deps/key.Plo

Performing manually

/opt/local/bin/g++-mp-7 -std=c++11 -DHAVE_CONFIG_H -I. -I../../../conf -I../../../src -fvisibility=hidden -I/opt/local/include -I/opt/local/include -DBUILDING_GPGMEPP -Wsuggest-override -Wzero-as-null-pointer-constant -I/opt/local/include -pipe -Os -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0 -arch ppc -E key.cpp -dD -H -fno-common -DPIC -o ~/key.ccp

leads to the following output, first on command line:

.
.
.
. engineinfo.h
. /usr/include/strings.h
. /opt/local/include/gcc7/c++/cassert
.. /usr/include/assert.h
... /opt/local/include/gcc7/c++/stdlib.h
.... /opt/local/include/gcc7/c++/cstdlib
. /opt/local/include/gcc7/c++/iterator
.. /opt/local/include/gcc7/c++/bits/stream_iterator.h
Multiple include guards may be useful for:
../../../conf/config.h
/opt/local/include/gcc7/c++/cassert
/opt/local/include/gcc7/c++/clocale
/opt/local/include/gcc7/c++/cstdio
/opt/local/include/gcc7/c++/cstring
/opt/local/include/gcc7/c++/cwctype
/opt/local/include/gcc7/c++/ppc-apple-darwin8/bits/ctype_base.h
/opt/local/include/gcc7/c++/ppc-apple-darwin8/bits/ctype_inline.h
/opt/local/include/gcc7/c++/stdlib.h
/usr/include/assert.h
/usr/include/strings.h
<finished here>

and here in the pre-processed output file:

33 "key.cpp" 2

  1. 1 "/usr/include/strings.h" 1 3 4
  2. 71 "/usr/include/strings.h" 3 4

71 "/usr/include/strings.h" 3 4

int bcmp(const void *, const void *, size_t);
void bcopy(const void *, void *, size_t);
void bzero(void *, size_t);
int ffs(int);
char *index(const char *, int);
char *rindex(const char *, int);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);

  1. 38 "key.cpp" 2

So it should build – but I have no idea of C++…

Details

External Link
https://trac.macports.org/ticket/69279
Version
GPGme 1.23.2

Event Timeline

It seems libtool fails to add the standard C and C++ libraries to the link command line. On Linux I have "[...] -lstdc++ -lm -lc [...]" in the libtool link command line. Looks like a bug in the tooling (macports or libtool).

Libtool invocation has "--tag=CXX --mode=link /opt/local/bin/g++-mp-7 -std=c++11 -pipe -Os -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0", but g++ then has no -lstdc++ – in C -lc is automatically used because there all C library functions can be taken from… (same for mathematical functions and -lm)

By adding "-Wl,-t" to the arguments g++ reported:

/usr/lib/dylib1.o
/opt/local/lib/gcc7/gcc/ppc-apple-darwin8/7.5.0/crt3.o
.libs/exception.o
.libs/context.o
.libs/key.o
.libs/trustitem.o
.libs/data.o

.libs/configuration.o
.libs/tofuinfo.o
.libs/swdbresult.o
.libs/util.o
.libs/context_vanilla.o
../../../src/.libs/libgpgme.dylib
/opt/local/lib/libgpg-error.dylib
/opt/local/lib/libassuan.dylib
/opt/local/lib/gcc7/libstdc++.dylib
/usr/lib/libgcc_s.10.4.dylib
/opt/local/lib/gcc7/libgcc_ext.10.4.dylib
/opt/local/lib/gcc7/gcc/ppc-apple-darwin8/7.5.0/libgcc.a
/usr/lib/libSystemStubs.a
/usr/lib/libSystem.dylib
/opt/local/lib/gcc7/gcc/ppc-apple-darwin8/7.5.0/libef_ppc.a
/usr/lib/system/libmathCommon.A.dylib
/opt/local/lib/gcc7/gcc/ppc-apple-darwin8/7.5.0/libef_ppc.a(darwin-gpsave.o)
Undefined symbols:

"strcasecmp(char const*, char const*)", referenced from:
    GpgME::Key::isRoot() const in key.o
    GpgME::Key::mergeWith(GpgME::Key const&) in key.o

ld: symbol(s) not found
collect2: error: ld returned 1 exit status

The linker used is "ld64_97", coming from http://opensource.apple.com/source/ld64/.

werner triaged this task as Normal priority.Mar 25 2024, 1:27 PM
werner added a subscriber: werner.

strcasecmp is pretty standard on Unix. However, in GnuPG we test for it and mostly use our own ascii_strcasecmp to avoid fun with locales. Ralph Seichter is providing macOS builds for GnuPG (https://sourceforge.net/p/gpgosx/docu/Download/) . Maybe it is worth to contact him via the gnugp-devel mailing list and ask him whether he has experience with your toochain.

Trying to reach Ralph Seichter via the eMail address he is using failed – Osterferien?

In two weeks possibly new try!

––

Pete

It seems my eMails to gnupg-devel@gnupg.org do reach the list …

Sorry, I meant they do *not* arrive at the web interface, they are not visible to me.

Meanwhile version 1.32.2 builds. Greatest change is Python 3.12 instead of 3.11…