Reputation: 122
I use cmake to help to complie a appliction with MinGW32 on Windows 8.1 x64 system.
The goal is to make a application can be run in windows from Windows XP to Windows 10 .
Using the combination of static and dynamic compilation ,Since some dll cannot find static libraries。
some major code
SET(toolchain_lib "E:/mingw32/lib" "E:/mingw32/lib/gcc/mingw32/5.3.0")
LINK_DIRECTORIES(${toolchain_lib})
target_link_libraries(${TARGET_NAME}
libgdi32.a
libglu32.a
#freeglut.dll
freeglut.a
libglew32.a
#libglew32.dll.a
opengl32.lib
libstdc++.a
libgcc.a
)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ /SUBSYSTEM:WINDOWS,5.1")
FILE (GLOB SRC_LIST "${src}/*.cpp" "${inc}/*.h")
ADD_EXECUTABLE(${TARGET_NAME} ${SRC_LIST})
cmake response:
[100%] Linking CXX executable ..\bin\sample_cube_picturebox_t.exe
g++.exe: error: /SUBSYSTEM:WINDOWS,5.1: No such file or directory
CMakeFiles\sample_cube_picturebox_t.dir\build.make:200: recipe for target '../bin/sample_cube_picturebox_t.exe' failed
make.exe[2]: *** [../bin/sample_cube_picturebox_t.exe] Error 1
CMakeFiles\Makefile2:81: recipe for target 'CMakeFiles/sample_cube_picturebox_t.dir/all' failed
make.exe[1]: *** [CMakeFiles/sample_cube_picturebox_t.dir/all] Error 2
Makefile:89: recipe for target 'all' failed
bin\make.exe: *** [all] Error 2
Upvotes: 0
Views: 481
Reputation: 7305
/SUBSYSTEM:WINDOWS,5.1
is not a GCC flag.
You probably want to use something line -D_WIN32_WINNT=0x0501
to specify Windows XP compatibility (see: https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-160)
Upvotes: 1