[QGIS-Developer] precompiled headers buggy, how to disable, compilation error
Greg Troxel
gdt at lexort.com
Mon Nov 3 14:54:15 PST 2025
This is a known problem with gcc, sort of addressed:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71934
After failing to disable pch with cmake, I edited the CMakeFiles where
target_precompiled_header existed and just removed it. Building again,
I don't get the warning, and things are mostly ok. One file failed to
build, and after fixing it (see below), I was able to get the build to
complete.
My question is:
Is there a way to add something to the cmake line to disable
precompiled headers? (It really seems like there should be.)
Greg
* src/core/pal/priorityqueue.cpp
I got a complaint that <memory> was likely missing. I am guessing that
somehow precompiled headers include it somehow when building in that
mode -- although that seems buggy.
I added a patch and it built. But obviously it's building for
~everybody else. I wonder if others, if you remove the
"target_precompiled_headers" line, can build this file.
The patch:
--- src/core/pal/priorityqueue.cpp.orig 2025-11-03 18:44:19.775172737 +0000
+++ src/core/pal/priorityqueue.cpp
@@ -28,6 +28,7 @@
*/
#include <cstdio>
+#include <memory>
#include "internalexception.h"
#include "priorityqueue.h"
The error output (without the patch):
FAILED: [code=1] src/core/CMakeFiles/qgis_core.dir/pal/priorityqueue.cpp.o
/tmp/work/geography/qgis/work/.cwrapper/bin/c++ -DCMAKE_SOURCE_DIR=\"/tmp/work/geography/qgis/work/qgis-3.44.4\" -DPROTOBUF_USE_DLLS -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_DISABLE_DEPRECATED_BEFORE=0x050800 -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_FOREACH -DQT_POSITIONING_LIB -DQT_PRINTSUPPORT_LIB -DQT_SERIALPORT_LIB -DQT_SQL_LIB -DQT_SVG_LIB -DQT_USE_QSTRINGBUILDER -DQT_WIDGETS_LIB -DQT_XML_LIB -DSIP_VERSION=0x060c00 -DTEST_DATA_DIR=\"/tmp/work/geography/qgis/work/qgis-3.44.4/tests/testdata\" -DWITH_COPC -DWITH_EPT -D_HAVE_PTHREAD_ -Dqgis_core_EXPORTS -I/tmp/work/geography/qgis/work/qgis-3.44.4/cmake-pkgsrc-build/src/core/qgis_core_autogen/include -I/tmp/work/geography/qgis/work/qgis-3.44.4/cmake-pkgsrc-build -I/tmp/work/geography/qgis/work/qgis-3.44.4/external/poly2tri -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/providers/ept -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/providers/copc -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/providers/vpc -I/tmp/work/geography/qgis/work/qgis-3.44.4/cmake-pkgsrc-build/src/core -I/tmp/work/geography/qgis/work/qgis-3.44.4/external/meshOptimizer -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/3d -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/actions -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/annotations -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/auth -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/browser -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/callouts -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/classification -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/diagram -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/dxf -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/editform -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/effects -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/elevation -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/expression -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/externalstorage -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/fieldformatter -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/geometry -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/geocoding -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/gps -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/labeling -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/labeling/rules -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/layertree -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/layout -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/locator -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/maprenderer -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/mesh -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/metadata -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/network -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/numericformats -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/painting -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pdf -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/plot -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pointcloud -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pointcloud/expression -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/processing -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/processing/models -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/proj -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/project -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/providers -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/providers/arcgis -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/providers/memory -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/providers/gdal -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/providers/ogr -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/providers/meshmemory -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/providers/sensorthings -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/raster -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/renderer -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/scalebar -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/settings -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/sensor -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/stac -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/symbology -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/textrenderer -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/tiledscene -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/validity -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/vector -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/vectortile -I/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/web -I/tmp/work/geography/qgis/work/qgis-3.44.4/external -I/tmp/work/geography/qgis/work/qgis-3.44.4/external/delaunator-cpp -I/tmp/work/geography/qgis/work/qgis-3.44.4/external/kdbush/include -I/tmp/work/geography/qgis/work/qgis-3.44.4/external/nmea -I/tmp/work/geography/qgis/work/qgis-3.44.4/external/rtree/include -I/tmp/work/geography/qgis/work/qgis-3.44.4/external/tinygltf -isystem /usr/pkg/qt5/include/Qca-qt5/QtCrypto -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtCore -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/./mkspecs/netbsd-g++ -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtGui -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtXml -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtWidgets -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtSvg -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtNetwork -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtSql -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtConcurrent -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtPositioning -isystem /tmp/work/geography/qgis/work/.buildlink/include/geos -isystem /usr/pkg/qt5/include -isystem /usr/pkg/qt5/include/QtDBus -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtPrintSupport -isystem /usr/pkg/include -isystem /tmp/work/geography/qgis/work/.buildlink/qt5/include/QtSerialPort -O2 -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/python3.13 -Dz_off_t=long -I/usr/pkg/include/libxml2 -I/usr/pkg/include/minizip -I/usr/pkg/qt5/include -I/usr/pkg/include/glib-2.0 -I/usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/harfbuzz -I/usr/pkg/include/freetype2 -I/usr/X11R7/include -I/usr/X11R7/include/libdrm -I/usr/pkg/include/gstreamer-1.0 -I/usr/pkg/qwt-6.3.0/include -Wall -Wextra -Wno-long-long -Wformat-security -Wno-strict-aliasing -Wnon-virtual-dtor -Wno-redundant-move -Wno-misleading-indentation -Wno-deprecated-copy -std=gnu++17 -fPIC -fvisibility=hidden -fPIC -MD -MT src/core/CMakeFiles/qgis_core.dir/pal/priorityqueue.cpp.o -MF src/core/CMakeFiles/qgis_core.dir/pal/priorityqueue.cpp.o.d -o src/core/CMakeFiles/qgis_core.dir/pal/priorityqueue.cpp.o -c /tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp
In file included from /tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:33:
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.h:96:12: error: 'unique_ptr' in namespace 'std' does not name a template type
96 | std::unique_ptr<int[]> heap;
| ^~~~~~~~~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.h:37:1: note: 'std::unique_ptr' is defined in header '<memory>'; did you forget to '#include <memory>'?
36 | #include <iostream>
+++ |+#include <memory>
37 |
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.h:97:12: error: 'unique_ptr' in namespace 'std' does not name a template type
97 | std::unique_ptr<double[]> p;
| ^~~~~~~~~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.h:97:7: note: 'std::unique_ptr' is defined in header '<memory>'; did you forget to '#include <memory>'?
97 | std::unique_ptr<double[]> p;
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.h:98:12: error: 'unique_ptr' in namespace 'std' does not name a template type
98 | std::unique_ptr<int[]> pos;
| ^~~~~~~~~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.h:98:7: note: 'std::unique_ptr' is defined in header '<memory>'; did you forget to '#include <memory>'?
98 | std::unique_ptr<int[]> pos;
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In constructor 'pal::PriorityQueue::PriorityQueue(int, int, bool)':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:53:3: error: 'heap' was not declared in this scope; did you mean 'upheap'?
53 | heap = std::make_unique<int[]>( maxsize );
| ^~~~
| upheap
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:53:15: error: 'make_unique' is not a member of 'std'
53 | heap = std::make_unique<int[]>( maxsize );
| ^~~~~~~~~~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:34:1: note: 'std::make_unique' is defined in header '<memory>'; did you forget to '#include <memory>'?
33 | #include "priorityqueue.h"
+++ |+#include <memory>
34 |
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:53:27: error: expected primary-expression before 'int'
53 | heap = std::make_unique<int[]>( maxsize );
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:54:3: error: 'p' was not declared in this scope
54 | p = std::make_unique<double[]>( maxsize );
| ^
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:54:12: error: 'make_unique' is not a member of 'std'
54 | p = std::make_unique<double[]>( maxsize );
| ^~~~~~~~~~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:54:12: note: 'std::make_unique' is defined in header '<memory>'; did you forget to '#include <memory>'?
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:54:24: error: expected primary-expression before 'double'
54 | p = std::make_unique<double[]>( maxsize );
| ^~~~~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:55:3: error: 'pos' was not declared in this scope
55 | pos = std::make_unique<int[]>( maxId + 1 );
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:55:14: error: 'make_unique' is not a member of 'std'
55 | pos = std::make_unique<int[]>( maxId + 1 );
| ^~~~~~~~~~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:55:14: note: 'std::make_unique' is defined in header '<memory>'; did you forget to '#include <memory>'?
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:55:26: error: expected primary-expression before 'int'
55 | pos = std::make_unique<int[]>( maxId + 1 );
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'int pal::PriorityQueue::getBest()':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:84:28: error: 'heap' was not declared in this scope; did you mean 'upheap'?
84 | const int return_value = heap[0];
| ^~~~
| upheap
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:88:3: error: 'pos' was not declared in this scope
88 | pos[heap[0]] = -1;
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:95:5: error: 'p' was not declared in this scope
95 | p[0] = p[size];
| ^
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'bool pal::PriorityQueue::isIn(int) const':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:105:26: error: 'pos' was not declared in this scope
105 | return key <= maxId && pos[key] >= 0;
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'int pal::PriorityQueue::getId(int) const':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:110:25: error: 'pos' was not declared in this scope
110 | return key <= maxId ? pos[key] : -1;
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'void pal::PriorityQueue::insert(int, double)':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:118:3: error: 'heap' was not declared in this scope; did you mean 'upheap'?
118 | heap[size] = key;
| ^~~~
| upheap
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:119:3: error: 'pos' was not declared in this scope
119 | pos[key] = size;
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:120:9: error: 'class pal::PriorityQueue' has no member named 'p'
120 | this->p[size] = p;
| ^
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'void pal::PriorityQueue::remove(int)':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:135:17: error: 'pos' was not declared in this scope
135 | const int i = pos[key];
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:140:9: error: 'heap' was not declared in this scope; did you mean 'upheap'?
140 | pos[heap[size]] = i;
| ^~~~
| upheap
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:144:5: error: 'p' was not declared in this scope
144 | p[i] = p[size];
| ^
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'void pal::PriorityQueue::upheap(int)':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:177:7: error: 'pos' was not declared in this scope
177 | i = pos[key];
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:183:21: error: 'p' was not declared in this scope
183 | if ( greater( p[PARENT( i )], p[i] ) )
| ^
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:187:13: error: 'heap' was not declared in this scope; did you mean 'upheap'?
187 | pos[heap[i]] = i2;
| ^~~~
| upheap
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'void pal::PriorityQueue::downheap(int)':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:220:30: error: 'p' was not declared in this scope
220 | min_child = greater( p[RIGHT( id )], p[LEFT( id )] ) ? LEFT( id ) : RIGHT( id );
| ^
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:228:19: error: 'p' was not declared in this scope
228 | if ( greater( p[id], p[min_child] ) )
| ^
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:230:7: error: 'pos' was not declared in this scope
230 | pos[heap[id]] = min_child;
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:230:11: error: 'heap' was not declared in this scope; did you mean 'upheap'?
230 | pos[heap[id]] = min_child;
| ^~~~
| upheap
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'void pal::PriorityQueue::setPriority(int, double)':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:255:17: error: 'pos' was not declared in this scope
255 | const int i = pos[key];
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:263:3: error: 'p' was not declared in this scope
263 | p[i] = new_p;
| ^
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'void pal::PriorityQueue::decreaseKey(int)':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:276:17: error: 'pos' was not declared in this scope
276 | const int i = pos[key];
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:281:3: error: 'p' was not declared in this scope
281 | p[i]--;
| ^
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'void pal::PriorityQueue::print()':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:297:72: error: 'heap' was not declared in this scope; did you mean 'upheap'?
297 | fprintf( stderr, "id: %7d -> key: %7d -> id: %7d p: %7f\n", i, heap[i], pos[heap[i]], p[i] );
| ^~~~
| upheap
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:297:81: error: 'pos' was not declared in this scope
297 | fprintf( stderr, "id: %7d -> key: %7d -> id: %7d p: %7f\n", i, heap[i], pos[heap[i]], p[i] );
| ^~~
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:297:95: error: 'p' was not declared in this scope
297 | fprintf( stderr, "id: %7d -> key: %7d -> id: %7d p: %7f\n", i, heap[i], pos[heap[i]], p[i] );
| ^
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp: In member function 'int pal::PriorityQueue::getSizeByPos() const':
/tmp/work/geography/qgis/work/qgis-3.44.4/src/core/pal/priorityqueue.cpp:310:10: error: 'pos' was not declared in this scope
310 | if ( pos[i] >= 0 )
| ^~~
More information about the QGIS-Developer
mailing list