Skip to content

feature/add pre cxx flags#15

Merged
el-dockerr merged 2 commits intomainfrom
feature/add-cxx-pre-flags
Nov 7, 2025
Merged

feature/add pre cxx flags#15
el-dockerr merged 2 commits intomainfrom
feature/add-cxx-pre-flags

Conversation

@el-dockerr
Copy link
Owner

This is linked to Issue: #14

g++  -I C:\VulkanSDK\1.4.328.1\Include C:\Windows\System32\vulkan-1.dll -I C:\GLFW\glfw-3.4.bin.WIN64\include -L C:\GLFW\glfw-3.4.bin.WIN64\lib-mingw-w64 -lglfw3 -lgdi32 -luser32  -std=c++17 -Wall -Wextra -Wpedantic...

A Vulkan/LGLFW compilation command has the correct structure for MinGW, but you are hitting the classic linker error: The library file must appear AFTER the source files or object files that depend on it.

The linker processes arguments from left to right. When it sees your source file, it notes all the undefined references (glfwInit, glfwCreateWindow, etc.). If it hasn't seen the GLFW library yet, it can't resolve those symbols, and the build fails.

The fix is simply a matter of reordering the elements in your command line. Therefore Bodge must have a representation for those orders to achieve more compatibility.

🛠️ The Corrected Command Order

Move the source file (src\main.cpp) and the Vulkan DLL path to the beginning, followed by all the GLFW and system library linking flags (-L and -l).

❌ Original (Failed) Order

g++ -I... C:\Windows\System32\vulkan-1.dll -I... -L C:\GLFW\... -lglfw3 -lgdi32 -luser32 src\main.cpp -o...
// Problem: The linker sees -lglfw3 AFTER src\main.cpp, but main.cpp needs glfw3 references resolved immediately.

✅ Correct (Working) Order

g++ -std=c++17 -Wall -Wextra -Wpedantic -O2 -m64 -static-libgcc -static-libstdc++ \
-I C:\VulkanSDK\1.4.328.1\Include \
-I C:\GLFW\glfw-3.4.bin.WIN64\include \
src\main.cpp \
C:\Windows\System32\vulkan-1.dll \
-L C:\GLFW\glfw-3.4.bin.WIN64\lib-mingw-w64 \
-lglfw3 -lgdi32 -luser32 \
-o vulcan_test.exe

@el-dockerr el-dockerr self-assigned this Nov 7, 2025
@el-dockerr el-dockerr added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request Code Improvements labels Nov 7, 2025
@el-dockerr el-dockerr linked an issue Nov 7, 2025 that may be closed by this pull request
@el-dockerr el-dockerr marked this pull request as ready for review November 7, 2025 17:24
@el-dockerr el-dockerr merged commit 28ff129 into main Nov 7, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Code Improvements documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linker must have options to link dependencies before sources

1 participant