Skip to content

Commit 7854bfc

Browse files
committed
[qtbase] Fix LNK2005 in consumers defining QT_DISABLE_DEPRECATED_BEFORE
On Windows static builds, compat/removed_api.cpp emits strong symbol definitions for deprecated APIs. If consumers compile with a higher QT_DISABLE_DEPRECATED_BEFORE value, those same functions become inline definitions in consumer translation units, causing LNK2005 duplicate symbol errors. Linux and macOS linkers silently resolve this by preferring the strong symbol, so the issue is Windows-only. Compiling removed_api.cpp with a high QT_DISABLE_DEPRECATED_BEFORE ensures its symbols are also emitted as inline definitions, which the linker silently deduplicates against consumer copies.
1 parent 8f54eb2 commit 7854bfc

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/src/corelib/CMakeLists.txt
2+
+++ b/src/corelib/CMakeLists.txt
3+
@@ -1637,3 +1637,8 @@
4+
qt_internal_library_deprecation_level()
5+
6+
+if(WIN32 AND NOT BUILD_SHARED_LIBS)
7+
+ set_source_files_properties(compat/removed_api.cpp
8+
+ PROPERTIES COMPILE_DEFINITIONS "QT_DISABLE_DEPRECATED_BEFORE=0x070000")
9+
+endif()
10+
+
11+
if(QT_FEATURE_doc_snippets)

ports/qtbase/portfile.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ set(${PORT}_PATCHES
2828
fix-libresolv-test.patch
2929
framework.patch
3030
use_inotify_on_freebsd.patch
31+
fix_removed_api_windows_static.patch
3132
)
3233

3334
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)

ports/qtbase/vcpkg.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "qtbase",
33
"version": "6.10.2",
4+
"port-version": 1,
45
"description": "Qt Base (Core, Gui, Widgets, Network, ...)",
56
"homepage": "https://www.qt.io/",
67
"license": null,

versions/baseline.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8274,7 +8274,7 @@
82748274
},
82758275
"qtbase": {
82768276
"baseline": "6.10.2",
8277-
"port-version": 0
8277+
"port-version": 1
82788278
},
82798279
"qtcharts": {
82808280
"baseline": "6.10.2",

versions/q-/qtbase.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"versions": [
3+
{
4+
"git-tree": "120102da8a67d76a929793b1dceb7906b893e696",
5+
"version": "6.10.2",
6+
"port-version": 1
7+
},
38
{
49
"git-tree": "0e931a0ffedd613937a8b9cad29f92087a7f83e8",
510
"version": "6.10.2",

0 commit comments

Comments
 (0)