CMake and Static Linking

I’ve managed to solve my problem by using the following: #Dynamic/Shared Libs … #Static start set_target_properties(icarus PROPERTIES LINK_SEARCH_START_STATIC 1) set_target_properties(icarus PROPERTIES LINK_SEARCH_END_STATIC 1) set(CMAKE_FIND_LIBRARY_SUFFIXES “.a”) #Static Libs … #Set Linker flags set(CMAKE_EXE_LINKER_FLAGS “-static-libgcc -static-libstdc++”) This works without passing a -static which creates other big issues, and can essentially mix static and dynamic libraries. As long … Read more

Static-linking of SDL2 libraries

It’s not necessary to recompile the library, SDL2 is given with static-link library named “libSDL2.a” on the folder “SDL2-2.0.0\i686-w64-mingw32\lib\”. Just be sure to add these options to the linker : “-lmingw32 -lSDL2main -lSDL2 -mwindows -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -static-libgcc” on Code:Blocks at “Project / Build Options… … Read more

How to generate statically linked executables?

Since Rust 1.19, you can statically link the C runtime (CRT) to avoid this very common situation on Windows: The program can’t start because VCRUNTIME140.dll is missing from your computer. Try reinstalling the program to fix this problem. Add this to your .cargo/config file, using the appropriate target triple for your platform: [target.x86_64-pc-windows-msvc] rustflags = … Read more