Reputation: 488
I've tried just about everything I can think of. I just cannot get SDL2 to output anything to the console. Both Windows PowerShell and Command Prompt show no output. There's also no stdout.txt file. cout, cerr, SDL_Log("..."), none work.
#define NO_STDIO_REDIRECT
#include <iostream>
#include "SDL.h"
using namespace std;
int main(int argc, char** args){
if (SDL_Init(SDL_INIT_VIDEO) != 0){
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Log("Hello World");
SDL_Quit();
return 0;
}
CMakeLists.txt:
message(STATUS "Print Test, CMAKE_SOURCE_DIR: " ${CMAKE_SOURCE_DIR})
cmake_minimum_required(VERSION 3.7)
project(testproject)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
#set(CMAKE_MODULE_PATH cmake/FindSDL2.cmake)
#set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(SDL2 REQUIRED)
include_directories(testproject ${SDL2_INCLUDE_DIRS})
add_executable(testproject src/main.cpp)
target_link_libraries(testproject ${SDL2_LIBRARIES})
Using GCC 4.8.3 (MinGW i686 Win-Builds 1.5)
Upvotes: 2
Views: 3256
Reputation:
Not sure if it's still relevant to you but have you tried the answer in No stdout.txt with SDL?
I used SDL 2 from MSYS2/MinGW-w64 where pkg-config
set the -mwindows
flag, which caused discarding of stdout
/stderr
when run from command prompt (but not with MSYS2 itself). Leaving out the -mwindows
flag helped.
Upvotes: 5