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

Fix linking when configured with -DENABLE_WALLET=OFF (Qt 6) #837

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Sep 18, 2024

This PR is a part of the transition to Qt 6.

When building with Qt 6 in my dev branch, I encountered a linker error when configured with -DENABLE_WALLET=OFF:

$ cmake -B build -DENABLE_WALLET=OFF -DBUILD_GUI=ON
$ cmake --build build -t bitcoin-qt
<snip>
[100%] Linking CXX executable bitcoin-qt
/usr/bin/ld: libbitcoinqt.a(rpcconsole.cpp.o): in function `QtPrivate::MetaObjectForType<WalletModel const*, void>::metaObjectFunction(QtPrivate::QMetaTypeInterface const*)':
/usr/include/x86_64-linux-gnu/qt6/QtCore/qmetatype.h:903:(.text._ZN9QtPrivate17MetaObjectForTypeIPK11WalletModelvE18metaObjectFunctionEPKNS_18QMetaTypeInterfaceE[_ZN9QtPrivate17MetaObjectForTypeIPK11WalletModelvE18metaObjectFunctionEPKNS_18QMetaTypeInterfaceE]+0x2b): undefined reference to `WalletModel::staticMetaObject'
/usr/bin/ld: libbitcoinqt.a(rpcconsole.cpp.o): in function `QMetaTypeIdQObject<WalletModel const*, 8>::qt_metatype_id()':
/usr/include/x86_64-linux-gnu/qt6/QtCore/qmetatype.h:1313:(.text._ZZN9QtPrivate16QMetaTypeForTypeIPK11WalletModelE17getLegacyRegisterEvENUlvE_4_FUNEv[_ZZN9QtPrivate16QMetaTypeForTypeIPK11WalletModelE17getLegacyRegisterEvENUlvE_4_FUNEv]+0x53): undefined reference to `WalletModel::staticMetaObject'
collect2: error: ld returned 1 exit status
gmake[3]: *** [src/qt/CMakeFiles/bitcoin-qt.dir/build.make:154: src/qt/bitcoin-qt] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:2107: src/qt/CMakeFiles/bitcoin-qt.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:2114: src/qt/CMakeFiles/bitcoin-qt.dir/rule] Error 2
gmake: *** [Makefile:998: bitcoin-qt] Error 2

This PR resolves the issue.

This change is required for Qt 6, but it is meaningful on its own.
@hebasto hebasto added the Qt 6 Transition to Qt 6 label Sep 18, 2024
@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 18, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK pablomartin4btc

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@fanquake
Copy link
Member

What is the error? Why does it only happen with Qt6?

@hebasto
Copy link
Member Author

hebasto commented Sep 18, 2024

What is the error?

I put it to the PR description.

Why does it only happen with Qt6?

Differences in Qt implementation between Qt 5 and Qt 6? (did not dig into the exact code change though)

Comment on lines +19 to +21
#ifdef ENABLE_WALLET
#include <qt/walletmodel.h>
#endif // ENABLE_WALLET
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How the RPCExecutor::request method compiles when this line doesn't exist?

Copy link
Contributor

@pablomartin4btc pablomartin4btc Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because the compiler only needs to know WalletModel, it doesn't need the full definition unless you dereference the pointer (eg as in RPCConsole::RPCParseCommandLine -> wallet_model->getWalletName() - which is guarded).

Copy link
Contributor

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 5be34ba

It builds correctly on Qt5 and qt runs fine, with both -DENABLE_WALLET=OFF & -DENABLE_WALLET=ON. When wallet support is off also tested the rpc console and several rpc commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Qt 6 Transition to Qt 6
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants