Skip to content

configure: link Windows OpenGL libraries and add loader test - #3390

Open
Lestropie wants to merge 4 commits into
masterfrom
compilation_gcc16_msys2
Open

configure: link Windows OpenGL libraries and add loader test#3390
Lestropie wants to merge 4 commits into
masterfrom
compilation_gcc16_msys2

Conversation

@Lestropie

Copy link
Copy Markdown
Member

Discovered while attempting to compile and test #3389.
Description in 080201e.

Diagnosed and fixed a Windows MSYS2 link failure in which the GUI
commands shview and mrview failed with undefined references to
wglGetProcAddress. Newer Qt5 / mingw-w64 packaging, together with the
stricter binutils linker shipped in the GCC 16 toolchain, no longer
lists the OpenGL import libraries in qmake's LIBS line nor pulls them in
transitively under --as-needed, leaving the direct wglGetProcAddress
call in gl_core_3_3.cpp unresolved. The configure script now appends
-lopengl32 and -lgdi32 to the GUI link flags on Windows so the OpenGL
dependency is satisfied. A new configure-time compile-and-link check
exercises the same per-platform OpenGL proc-address resolver used by
gl_core_3_3.cpp, reproducing the GUI link dependency so a missing OpenGL
library aborts configuration with a clear message instead of surfacing
later during the build.

Session prompts:
1. > Attempting to compile this branch in Windows MSYS2 with a fresh configuration fails with the compilation message pasted below. There have recently been compilation / linking issues with this project on Windows MSYS2 due to changes introduced in GCC 16. Investigate and propose modifications to try. Note that the filesystem structure and compilation process differ on this branch to that for which Claude has been provided instructions.
   > ERROR: (11/88) [LB] bin/shview.exe
   > g++ tmp/src/gui/opengl/font.o tmp/src/gui/dialog/report_exception.o tmp/src/gui/shapes/halfsphere.o tmp/src/dwi/directions/predefined.o tmp/src/gui/dwi/render_frame.o tmp/cmd/shview.o tmp/src/gui/shview/render_window.o tmp/src/dwi/directions/set.o tmp/src/gui/dialog/dialog.o tmp/src/gui/crosshair.o tmp/src/gui/opengl/shader.o tmp/src/gui/dwi/render_frame_moc.o tmp/src/gui/shview/file_open.o tmp/src/exec_version.o tmp/src/gui/dialog/file.o tmp/src/gui/dialog/progress.o tmp/src/gui/gui.o tmp/src/gui/lighting_dock.o tmp/src/gui/lighting_dock_moc.o tmp/src/gui/dwi/renderer.o tmp/src/gui/projection.o tmp/src/gui/opengl/gl_core_3_3.o tmp/src/gui/color_button.o tmp/src/gui/opengl/gl.o tmp/src/gui/shview/icons.o tmp/src/gui/color_button_moc.o tmp/src/gui/opengl/lighting.o tmp/src/gui/shview/render_window_moc.o tmp/src/gui/dialog/list.o tmp/src/gui/opengl/lighting_moc.o tmp/src/gui/dialog/dicom.o -lmrtrix -Wl,--sort-common,--as-needed -pthread -Wl,--allow-multiple-definition -lz -ltiff -lpng16 -lfftw3 -L./bin C:/msys64/mingw64/lib/libQt5OpenGL.dll.a C:/msys64/mingw64/lib/libQt5Svg.dll.a C:/msys64/mingw64/lib/libQt5Widgets.dll.a C:/msys64/mingw64/lib/libQt5Gui.dll.a C:/msys64/mingw64/lib/libQt5Network.dll.a C:/msys64/mingw64/lib/libQt5Core.dll.a -lmingw32 C:/msys64/mingw64/lib/libqtmain.a -lshell32 -o bin/shview.exe
   > failed with output
   > C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/src/gui/opengl/gl_core_3_3.o:gl_core_3_3.cpp:(.text+0x5e): undefined reference to `__imp_wglGetProcAddress'
   > C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/src/gui/opengl/gl_core_3_3.o:gl_core_3_3.cpp:(.text+0x11d): undefined reference to `__imp_wglGetProcAddress'
   > C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/src/gui/opengl/gl_core_3_3.o:gl_core_3_3.cpp:(.text+0x18d): undefined reference to `__imp_wglGetProcAddress'
   > C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/src/gui/opengl/gl_core_3_3.o:gl_core_3_3.cpp:(.text+0x1fd): undefined reference to `__imp_wglGetProcAddress'
   > C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/src/gui/opengl/gl_core_3_3.o:gl_core_3_3.cpp:(.text+0x26d): undefined reference to `__imp_wglGetProcAddress'
   > C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/src/gui/opengl/gl_core_3_3.o:gl_core_3_3.cpp:(.text+0x2e0): more undefined references to `__imp_wglGetProcAddress' follow
   > collect2.exe: error: ld returned 1 exit status
2. > Within the configure script, add a new test command for compilation & linking that would have resulted in catching this linking fault during execution of the configure script.

Generated-by: Claude Opus 4.8 <noreply@anthropic.com>
@Lestropie Lestropie self-assigned this Jun 6, 2026
@Lestropie Lestropie mentioned this pull request Jun 6, 2026
27 tasks
jdtournier
jdtournier previously approved these changes Jun 17, 2026
@jdtournier
jdtournier enabled auto-merge June 17, 2026 10:44
@jdtournier
jdtournier disabled auto-merge June 17, 2026 10:45
@jdtournier

Copy link
Copy Markdown
Member

Seems there are additional issues introduced with C++14:

clang++ -c -std=c++14 -DMRTRIX_BUILD_TYPE="release version with asserts" -pthread -fPIC -Werror -DMRTRIX_WORD64 -DMRTRIX_NO_VLA -DMRTRIX_NO_NON_POD_VLA -DMRTRIX_HAVE_EIGEN_UNSUPPORTED_SPECIAL_FUNCTIONS -DMRTRIX_PNG_SUPPORT -isystem /usr/include/libpng16 -DEIGEN_FFTW_DEFAULT -Wall -O3 -D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1 -Isrc -I./core -Icmd -isystem /home/runner/work/mrtrix3/mrtrix3/eigen-5.0.0 -DEIGEN_DONT_PARALLELIZE cmd/transformcalc.cpp -o tmp/cmd/transformcalc.o

failed with output

cmd/transformcalc.cpp:281:40: error: 'eulerAngles' is deprecated: Use .canonicalEulerAngles() instead. [-Werror,-Wdeprecated-declarations]
  281 |       Eigen::Vector3d euler_angles = R.eulerAngles(0, 1, 2);
      |                                        ^
/home/runner/work/mrtrix3/mrtrix3/eigen-5.0.0/Eigen/src/Core/MatrixBase.h:396:3: note: 'eulerAngles' has been explicitly marked deprecated here
  396 |   EIGEN_DEPRECATED_WITH_REASON("Use .canonicalEulerAngles() instead.")
      |   ^

and

core/math/stats/shuffle.cpp:465:20: error: 'random_shuffle<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<unsigned long *, std::__cxx1998::vector<unsigned long>>, std::vector<unsigned long>>>' is deprecated: use 'std::shuffle' instead [-Werror,-Wdeprecated-declarations]
  465 |               std::random_shuffle (permuted_labelling.begin(), permuted_labelling.end());
      |                    ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_algo.h:4489:5: note: 'random_shuffle<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<unsigned long *, std::__cxx1998::vector<unsigned long>>, std::vector<unsigned long>>>' has been explicitly marked deprecated here

There may be other warnings too, hard to tell given how often these ones popped up in the output...

@Lestropie

Copy link
Copy Markdown
Member Author

Residual compilation errors are exclusively on the Eigen 5 workflow, which should be rectified by #3409.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants