Repository navigation
Description
platform:
win11 + clang-cl + qt5.15.2
or
win11 + msvc + qt5.15.2
all qt examples got such errors:
[build] LINK: command "C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\Llvm\x64\bin\lld-link.exe /nologo examples\qt\graph1\CMakeFiles\qtgraph1.dir\qtgraph1_autogen\mocs_compilation.cpp.obj examples\qt\graph1\CMakeFiles\qtgraph1.dir\main.cpp.obj /out:examples\qt\graph1\qtgraph1.exe /implib:examples\qt\graph1\qtgraph1.lib /pdb:examples\qt\graph1\qtgraph1.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console C:\Qt\5.15.2\msvc2019_64\lib\Qt5OpenGL.lib C:\Qt\5.15.2\msvc2019_64\lib\Qt5Widgets.lib C:\Qt\5.15.2\msvc2019_64\lib\Qt5Gui.lib C:\Qt\5.15.2\msvc2019_64\lib\Qt5Core.lib D:\github\vcpkg\installed\x64-windows\lib\freetype.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=1" failed (exit code 1) with the following output:
[build] lld-link: error: undefined symbol: __declspec(dllimport) glGetError
[build] >>> referenced by examples\qt\graph1\CMakeFiles\qtgraph1.dir\main.cpp.obj:(unsigned int __cdecl mplot::gl::Util::checkError(char const *, int))
[build] >>> referenced by examples\qt\graph1\CMakeFiles\qtgraph1.dir\main.cpp.obj:(unsigned int __cdecl mplot::gl::Util::checkError(char const *, int))
[build] >>> referenced by examples\qt\graph1\CMakeFiles\qtgraph1.dir\main.cpp.obj:(unsigned int __cdecl mplot::gl::LoadShaders(class std::vector<struct mplot::gl::ShaderInfo, class std::allocator<struct mplot::gl::ShaderInfo>> const &))
[build]
[build] lld-link: error: undefined symbol: glCreateProgram
[build] >>> referenced by examples\qt\graph1\CMakeFiles\qtgraph1.dir\main.cpp.obj:(unsigned int __cdecl mplot::gl::LoadShaders(class std::vector<struct mplot::gl::ShaderInfo, class std::allocator<struct mplot::gl::ShaderInfo>> const &))
[build]
[build] lld-link: error: undefined symbol: __declspec(dllimport) glGetBooleanv
[build] >>> referenced by examples\qt\graph1\CMakeFiles\qtgraph1.dir\main.cpp.obj:(unsigned int __cdecl mplot::gl::LoadShaders(class std::vector<struct mplot::gl::ShaderInfo, class std::allocator<struct mplot::gl::ShaderInfo>> const &))
[build]
[build] lld-link: error: undefined symbol: glCreateShader
[build] >>> referenced by examples\qt\graph1\CMakeFiles\qtgraph1.dir\main.cpp.obj:(unsigned int __cdecl mplot::gl::LoadShaders(class std::vector<struct mplot::gl::ShaderInfo, class std::allocator<struct mplot::gl::ShaderInfo>> const &))
[build]
[build] lld-link: error: undefined symbol: glShaderSource
[build] >>> referenced by examples\qt\graph1\CMakeFiles\qtgraph1.dir\main.cpp.obj:(unsigned int __cdecl mplot::gl::LoadShaders(class std::vector<struct mplot::gl::ShaderInfo, class std::allocator<struct mplot::gl::ShaderInfo>> const &))
I tried to link Qt5::OpenGL instead, it also doesn't work
Metadata
Metadata
Assignees
Labels
No labels
Activity
sebsjames commentedon Jul 22, 2025
I added some missing include lines, see if that fixes the compiler error for you.
sebsjames commentedon Jul 22, 2025
I've merged the change, as it was correct to add the includes in. I've left this issue open, so please close it if your problem has vanished on current main.
miyanyan commentedon Jul 23, 2025
still got these errors, I think it's maybe something that doesn't link opengl properly?
sebsjames commentedon Jul 23, 2025
Ah, so you're right. I didn't read the original error messages carefully enough. Seems like this is probably Qt shared object libraries being linked to OpenGL on Linux/Mac but not on Windows.
sebsjames commentedon Jul 23, 2025
It may also be a question of GL header inclusion.
sebsjames commentedon Jul 23, 2025
I think the problem might be GL header inclusion (as the build process appears to be linking to opengl already).
When we use OpenGL, we have to define function names that map to the internal function names. One way to do this is to use GLAD (which I do in mathplot). Qt does this itself with the QOpenGLFunctions_* classes.
There is a note at the top of mplot/qt/viswidget.h:
So, on platforms that I've tested Qt with (i.e. Linux), when you
#include <QOpenGLFunctions_4_1_Core>, the function mapping is made so that when we#include <mplot/VisualOwnableNoMX.h>and start preprocessing that file we process this:You could add some pragma message lines to that section (or something that will emit a message for your compiler) like this:
On Linux with gcc I get this output when building qtgraph1 with the above change to mplot/VisualOwnableNoMX.h:
[seb@GPU3090 10:36:13 build]$ make qtgraph1 [ 0%] Built target qtgraph1_autogen_timestamp_deps [ 50%] Built target qtgraph1_autogen [ 50%] Building CXX object examples/qt/graph1/CMakeFiles/qtgraph1.dir/main.cpp.o In file included from /home/seb/src/mathplot/mplot/qt/viswidget.h:15, from /home/seb/src/mathplot/examples/qt/graph1/main.cpp:3: /home/seb/src/mathplot/mplot/VisualOwnableNoMX.h:21:17: note: ‘#pragma message: GL headers appear to have been externally included’ 21 | #pragma message "GL headers appear to have been externally included" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 50%] Linking CXX executable qtgraph1 [100%] Built target qtgraph1 [seb@GPU3090 10:37:03 build]$Could you try this and see what output you get?
miyanyan commentedon Jul 23, 2025
I got the same output:
sebsjames commentedon Jul 24, 2025
Maybe the best way to approach this is for me to get the same error you have on a Windows machine. Can you tell me how you installed dependencies and carried out the build? You could even write notes into a PR for https://github.com/sebsjames/mathplot/blob/main/README.build.windows.md
I can then try to build and see if I get the same link error and can try to fix locally.