1

When I run a simple "Hello World" program it finishes with exit code 0 without printing anything.

This is my CMakeLists.txt file:

cmake_minimum_required(VERSION 3.7)
project(TEST)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${TEST_SOURCE_DIR}/cmake")
set(CMAKE_C_STANDARD 99)

find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)

include_directories(${SDL2_INCLUDE_DIR}
                    ${SDL2_IMAGE_INCLUDE_DIR})

set(SOURCE_FILES main.c)
add_executable(TEST ${SOURCE_FILES})

target_link_libraries(TEST ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARIES})

This is my program that doesn't print to console:

#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    return 0;
}

If I remove this line from my CMakeLists.txt file it does print but then I of course can't include SDL.

target_link_libraries(TEST ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARIES})

Any ideas?

arved
  • 4,401
  • 4
  • 30
  • 53
Pepe Silvia
  • 81
  • 1
  • 8
  • Possible duplicate of [Printf is not printing anything to output? C++ SDL](http://stackoverflow.com/questions/11068565/printf-is-not-printing-anything-to-output-c-sdl) – arved Apr 06 '17 at 09:33

0 Answers0