when creating an application with SFML on Windows usually a console-window appears next to (or behind) the application-window.
To get rid of it you have to tell CMake that its going to be a windows-application and link against sfml-main-lib.
Telling CMake you're writing an windows application is done with:
Unfortunately this forces you to use
as application-entry-point and therefore include "windows.h" in the main.cpp, which makes the codebase plattform-specific. This can be avoided by linking against sfml-main-lib.
CMakeLists.txt should look similar to this:
now you should be able to compile the program with a simple entry-function like
and getting an application-window without a console-window.
To get rid of it you have to tell CMake that its going to be a windows-application and link against sfml-main-lib.
Telling CMake you're writing an windows application is done with:
1 | add_executable(${PROJECT_NAME} WIN32 ${SOURCES}) |
Unfortunately this forces you to use
1 | int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) |
as application-entry-point and therefore include "windows.h" in the main.cpp, which makes the codebase plattform-specific. This can be avoided by linking against sfml-main-lib.
CMakeLists.txt should look similar to this:
1 2 3 4 5 6 7 8 9 10 11 | cmake_minimum_required(VERSION 3.0) project(YourProjectName) set(SFML_ROOT "C:/Program Files (x86)/SFML") set(SOURCES main.cpp ...) find_package(SFML COMPONENTS System Window Graphics Main) include_directories(${SFML_INCLUDE_DIR}) add_executable(${PROJECT_NAME} WIN32 ${SOURCES}) target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES}) |
now you should be able to compile the program with a simple entry-function like
1 | int main()
|
and getting an application-window without a console-window.