Page MenuHome GnuPG

Linking error with GPGMEPP on MacOS Tahoe 26.01/GCC 15.2
Open, Needs TriagePublic

Description

Consider the following code:

#include "gpgme++/context.h"
#include "gpgme++/data.h"
#include "gpgme++/importresult.h"
#include <memory>
#include <print>

const char* data = "this should not be imported";

int main()
{
    GpgME::initializeLibrary();
    const std::unique_ptr<GpgME::Context> ctx {
        GpgME::Context::createForProtocol(GpgME::OpenPGP)
    };
    auto buffer = GpgME::Data(data, strlen(data), true);
    auto errcode = ctx->importKeys(buffer);
    if (errcode.error().isError()) {
      std::println(stderr, "Couldn’t import key: {}",
        errcode.error().asStdString());
    }
    return 0;
}

Environment:

  • macOS Tahoe 26.1
  • M4 processor (aarch64/arm64)
  • Apple Clang 17 (supplied by XCode)
  • GNU C++ 15.2 (supplied by Homebrew)
  • GPGMEPP 2.0.0 (supplied by Homebrew)

Expected result:
Code should compile and link cleanly.

Actual result:

  • When compiling with Apple Clang, the code compiles and links cleanly.
  • When compiling with GNU C++ 15.2, the following linking error occurs:
Undefined symbols for architecture arm64:
  "GpgME::Error::asStdString[abi:cxx11]() const", referenced from:
      _main in cc3RBL1t.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status

Details

Version
2.0.0

Event Timeline

Please show the command line of the linker.

Please check if you can reproduce the problem if you built gpgmepp yourself with GCC.

g++-15 foo.cc `pkg-config --cflags --libs gpgmepp` -o foo -O2 -Wall --std=c++23

I'll see about rebuilding GPGMEPP with G++ 15 and check back in.