Wireshark-dev: Re: [Wireshark-dev] Qt link errors (Q_INIT_RESOURCE)
From: Martin Mathieson <martin.r.mathieson@xxxxxxxxxxxxxx>
Date: Wed, 31 Mar 2021 09:55:46 +0100
cmake --version
cmake version 3.5.2
cmake version 3.5.2
qmake-qt5 --version
QMake version 3.0
Using Qt version 5.6.2 in /usr/lib64
QMake version 3.0
Using Qt version 5.6.2 in /usr/lib64
This is an old VM that will be retired in around a month when a new machine arrives.
- Configuring done
Warning: Source file "/home/martin/wireshark_gl-build/ui/qt/CMakeFiles/qtui.dir/qrc_languages.cpp" is listed multiple times for target "qtui".
Warning: Source file "/home/martin/wireshark_gl-build/ui/qt/CMakeFiles/qtui.dir/qrc_layout.cpp" is listed multiple times for target "qtui".
Warning: Source file "/home/martin/wireshark_gl-build/ui/qt/CMakeFiles/qtui.dir/qrc_stock_icons.cpp" is listed multiple times for target "qtui".
Warning: Source file "/home/martin/wireshark_gl-build/ui/qt/CMakeFiles/qtui.dir/qrc_wsicon.cpp" is listed multiple times for target "qtui".
Warning: Source file "/home/martin/wireshark_gl-build/ui/qt/CMakeFiles/qtui.dir/qrc_i18n.cpp" is listed multiple times for target "qtui".
-- Generating done
-- Build files have been written to: /home/martin/wireshark_gl-build
Warning: Source file "/home/martin/wireshark_gl-build/ui/qt/CMakeFiles/qtui.dir/qrc_languages.cpp" is listed multiple times for target "qtui".
Warning: Source file "/home/martin/wireshark_gl-build/ui/qt/CMakeFiles/qtui.dir/qrc_layout.cpp" is listed multiple times for target "qtui".
Warning: Source file "/home/martin/wireshark_gl-build/ui/qt/CMakeFiles/qtui.dir/qrc_stock_icons.cpp" is listed multiple times for target "qtui".
Warning: Source file "/home/martin/wireshark_gl-build/ui/qt/CMakeFiles/qtui.dir/qrc_wsicon.cpp" is listed multiple times for target "qtui".
Warning: Source file "/home/martin/wireshark_gl-build/ui/qt/CMakeFiles/qtui.dir/qrc_i18n.cpp" is listed multiple times for target "qtui".
-- Generating done
-- Build files have been written to: /home/martin/wireshark_gl-build
If I move the Q_INIT_RESOURCE() calls to main.cpp (just before ws_app is created), I still get the link error.
Moving the CMAKE_AUTO stuff back to the top-level CMakeLists.txt does fix this for me, i.e.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ebc42d736b..161e978ce2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1135,9 +1135,6 @@ ws_find_package(Systemd BUILD_sdjournal HAVE_SYSTEMD)
# Build the Qt GUI?
if(BUILD_wireshark)
- set(CMAKE_AUTOMOC ON)
- set(CMAKE_AUTOUIC ON)
- set(CMAKE_AUTORCC ON)
# Untested, may not work if CMAKE_PREFIX_PATH gets overwritten
# somewhere. The if WIN32 in this place is annoying as well.
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index 2e08d60832..a63829eb61 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -630,6 +630,11 @@ set(WIRESHARK_QT_QRC
${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc
)
+set(CMAKE_AUTOMOC TRUE)
+set(CMAKE_AUTOUIC TRUE)
+set(CMAKE_AUTORCC TRUE)
+
+
if(NOT Qt5Widgets_VERSION VERSION_LESS "5.9")
# Drop the file modification time of source files from generated files
# to help with reproducible builds. We do not use QFileInfo.lastModified
index ebc42d736b..161e978ce2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1135,9 +1135,6 @@ ws_find_package(Systemd BUILD_sdjournal HAVE_SYSTEMD)
# Build the Qt GUI?
if(BUILD_wireshark)
- set(CMAKE_AUTOMOC ON)
- set(CMAKE_AUTOUIC ON)
- set(CMAKE_AUTORCC ON)
# Untested, may not work if CMAKE_PREFIX_PATH gets overwritten
# somewhere. The if WIN32 in this place is annoying as well.
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index 2e08d60832..a63829eb61 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -630,6 +630,11 @@ set(WIRESHARK_QT_QRC
${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc
)
+set(CMAKE_AUTOMOC TRUE)
+set(CMAKE_AUTOUIC TRUE)
+set(CMAKE_AUTORCC TRUE)
+
+
if(NOT Qt5Widgets_VERSION VERSION_LESS "5.9")
# Drop the file modification time of source files from generated files
# to help with reproducible builds. We do not use QFileInfo.lastModified
Martin
On Wed, Mar 31, 2021 at 12:38 AM Gerald Combs <gerald@xxxxxxxxxxxxx> wrote:
What versions of CMake and Qt are you using? I enabled CMAKE_AUTORCC earlier on in the configuration process in be2b0fc810, which might have caused this. You might try moving `set(CMAKE_AUTO...` back to ui/qt/CMakeLists.txt, but if that fixes the problem then we might have to enable CMAKE_AUTO* earlier or later depending on our CMake version.
I also noticed that https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE says
"This macro cannot be used in a namespace. It should be called from main()."
Maybe we need to move our Q_INIT_RESOURCE calls from wireshark_application.cpp to main.cpp?
On 3/30/21 2:15 AM, Martin Mathieson via Wireshark-dev wrote:
> I started getting this link error a day or 2 back:
>
> [ 98%] Linking CXX executable run/wireshark
> /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: ui/qt/CMakeFiles/qtui.dir/wireshark_application.cpp.o: in function `WiresharkApplication::WiresharkApplication(int&, char**)':
> /home/martin/wireshark_gl/ui/qt/wireshark_application.cpp:639: undefined reference to `qInitResources_about()'
> /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: /home/martin/wireshark_gl/ui/qt/wireshark_application.cpp:640: undefined reference to `qInitResources_i18n()'
> /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: /home/martin/wireshark_gl/ui/qt/wireshark_application.cpp:641: undefined reference to `qInitResources_layout()'
> /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: /home/martin/wireshark_gl/ui/qt/wireshark_application.cpp:642: undefined reference to `qInitResources_stock_icons()'
> /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: /home/martin/wireshark_gl/ui/qt/wireshark_application.cpp:643: undefined reference to `qInitResources_wsicon()'
> /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: /home/martin/wireshark_gl/ui/qt/wireshark_application.cpp:644: undefined reference to `qInitResources_languages()'
> collect2: error: ld returned 1 exit status
>
> Haven't worked out exactly why this is happening (or at which commit it started to fail). If I do need to update Qt, the minimum version check in CMake isn't catching it.
>
> Martin
>
>
> ___________________________________________________________________________
> Sent via: Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
> Archives: https://www.wireshark.org/lists/wireshark-dev
> Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
> mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe
>
- Follow-Ups:
- Re: [Wireshark-dev] Qt link errors (Q_INIT_RESOURCE)
- From: Gerald Combs
- Re: [Wireshark-dev] Qt link errors (Q_INIT_RESOURCE)
- References:
- [Wireshark-dev] Qt link errors (Q_INIT_RESOURCE)
- From: Martin Mathieson
- Re: [Wireshark-dev] Qt link errors (Q_INIT_RESOURCE)
- From: Gerald Combs
- [Wireshark-dev] Qt link errors (Q_INIT_RESOURCE)
- Prev by Date: Re: [Wireshark-dev] Failed pipeline for nvmeof_getlog_page | wireshark | 3a8e09ef
- Next by Date: [Wireshark-dev] overzealous tcpros_tcp detection
- Previous by thread: Re: [Wireshark-dev] Qt link errors (Q_INIT_RESOURCE)
- Next by thread: Re: [Wireshark-dev] Qt link errors (Q_INIT_RESOURCE)
- Index(es):