Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: interface dependency /usr/lib64/lib{gtk-4}@/usr/bin/g++/ is unknown #2

Open
wroyca opened this issue Jun 26, 2024 · 0 comments
Labels
help wanted Extra attention is needed information Further information is requested

Comments

@wroyca
Copy link
Collaborator

wroyca commented Jun 26, 2024

Interface dependencies act up when attempting to use libadwaita in a C++ package. No amount of tweaking resolves the situation, whether switching from c to cc or trying various methods to export (cc.export.libs, c.export.libs, etc.).

error: interface dependency /usr/lib64/liba{gtk4}@/usr/bin/g++/ is unknown
  info: mentioned in *.export.libs of target ../foo-gcc/libadwaita-1.5.0+4/libadwaita/libs{adwaita}
  info: is it a prerequisite of ../foo-gcc/libadwaita-1.5.0+4/libadwaita/libs{adwaita}?
  info: while applying rule cxx.compile to update ../foo-gcc/libfoo/libfoo/objs{foo}
  info: while applying rule cxx.link to update ../foo-gcc/libfoo/libfoo/libs{foo}
  info: while applying rule cxx.link to update ../foo-gcc/foo/foo/exe{foo}
  info: while applying rule build.alias to update ../foo-gcc/foo/dir{foo/}
  info: while applying rule build.alias to update ../foo-gcc/dir{foo/}
error: interface dependency /usr/lib64/libs{gtk4}@/usr/bin/g++/ is unknown
  info: mentioned in *.export.libs of target ../foo-gcc/libadwaita-1.5.0+4/libadwaita/liba{adwaita}
  info: is it a prerequisite of ../foo-gcc/libadwaita-1.5.0+4/libadwaita/liba{adwaita}?
  info: while applying rule cxx.compile to update ../foo-gcc/libfoo/libfoo/obja{foo}
  info: while applying rule cxx.link to update ../foo-gcc/libfoo/libfoo/liba{foo}
  info: while applying rule bin.lib to update ../foo-gcc/libfoo/libfoo/lib{foo}
  info: while applying rule build.alias to update ../foo-gcc/libfoo/dir{libfoo/}
  info: while applying rule build.alias to update ../foo-gcc/dir{libfoo/}

Attempting a minimal C library linked in a C++ project setup works, so I suspect there's something else I'm missing, or perhaps there's something unusual in the GTK pkg-config file. For now, the workaround involves forcing config.c to use g++:

#!/usr/bin/env bash

if ! cat /etc/os-release | grep -q "Fedora"; then
  echo "Warning: Your distribution is not Fedora, which may result in outdated GTK."
fi

set -x

bdep new -t empty foo
bdep new -t empty bar
bdep new -t empty baz

cd foo

bdep new --package -l c++ -t exe foo
bdep new --package -l c++ -t lib libfoo

cd ../bar

bdep new --package -l c -t lib libbar

cd ../baz

bdep new --package -l c -t lib libbaz

cd ..

# Configure dependencies repositories

cat <<EOF > foo/repositories.manifest
: 1
summary: foo project repository

:
role: prerequisite
location: ../bar.git#main

:
role: prerequisite
location: https://github.com/build2-packaging/libadwaita.git#main

#:
#role: prerequisite
#location: ../libadwaita.git#main
EOF

cat <<EOF > bar/repositories.manifest
: 1
summary: bar project repository

:
role: prerequisite
location: ../baz.git#main
EOF

# Update dependency declarations in project manifests.

sed -i 's/#depends: libhello \^1\.0\.0/depends: libfoo == $/'                 foo/foo/manifest
sed -i 's/#depends: libhello \^1\.0\.0/depends: libbar\ndepends: libadwaita/' foo/libfoo/manifest
sed -i 's/#depends: libhello \^1\.0\.0/depends: libbaz/'                      bar/libbar/manifest

# Update dependency declarations in packages buildfile

sed -i 's/#import libs += libhello%lib{hello}/import libs += libfoo%lib{foo}/'                                   foo/foo/foo/buildfile
sed -i 's/#import xxxx_libs += libhello%lib{hello}/import intf_libs += libbar%lib{bar} libadwaita%lib{adwaita}/' foo/libfoo/libfoo/buildfile
sed -i 's/#import xxxx_libs += libhello%lib{hello}/import intf_libs += libbaz%lib{baz}/'                         bar/libbar/libbar/buildfile

# Disable tests in bar.

rm -rf bar/libbar/tests

# Override bar source code to export "hello"

cat <<EOF > bar/libbar/libbar/bar.c
#include <libbar/bar.h>

int
hello ()
{
  return 0;
}
EOF

cat <<EOF > bar/libbar/libbar/bar.h
#pragma once

#include <libbar/export.h>

#ifdef __cplusplus
extern "C"
{
#endif

LIBBAR_SYMEXPORT int
hello ();

#ifdef __cplusplus
}
#endif
EOF

# Override foo source code to import "hello" and "adw_init" from bar and libadwaita, respectively.

cat <<EOF > foo/libfoo/libfoo/foo.cxx
#include <libfoo/foo.hxx>
#include <libbar/bar.h>
#include <adwaita.h>

#include <ostream>
#include <stdexcept>

using namespace std;

namespace foo
{
  void say_hello (ostream& o, const string& n)
  {
    hello ();

    adw_init();

    if (n.empty ())
      throw invalid_argument ("empty name");

    o << "Hello, " << n << '!' << endl;
  }
}
EOF

# Commit above sed operations.

cd foo
git add .
git commit -m "Initial commit"

cd ../bar
git add .
git commit -m "Initial commit"

cd ../baz
git add .
git commit -m "Initial commit"

# Now we'll attempt to build foo along with its dependencies.
#

cd ../foo

c='\e[1;33m'
r='\e[1;0m'

set +x

echo -e "$(
cat << EOM
${c}Initial attempt.${r}
EOM
)"

set -x

bdep init -C @gcc cc
bdep update

set +x

echo -e "$(
cat << EOM
${c}Second attempt. Force config.c to `g++`${r}
EOM
)"

set -x

rm -rf .bdep/
bdep init -C @gcc cc config.c=g++ --wipe
bdep update

set +x

Also related: https://cpplang.slack.com/archives/CDJ0Z991S/p1720210865895529?thread_ts=1710423736.413539&cid=CDJ0Z991S

@wroyca wroyca added the information Further information is requested label Jun 27, 2024
@wroyca wroyca added the help wanted Extra attention is needed label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed information Further information is requested
Development

No branches or pull requests

1 participant