原因:
CMAKE 设置了 WIN32_EXECUTABLE TRUE
这表示了要生成一个 GUI 程序, 而且 Windows GUI 会禁用控制台输出
将
set_target_properties(aa PROPERTIES WIN32_EXECUTABLE TRUE)
修改为
set_target_properties(aa PROPERTIES WIN32_EXECUTABLE FALSE)
或者手动创建控制台:
` //未验证
ifdef _WIN32
include <windows.h>
include
void CreateConsole() {
AllocConsole();
FILE* fp;
freopen_s(&fp, "CONOUT\(", "w", stdout);
freopen_s(&fp, "CONOUT\)", "w", stderr);
freopen_s(&fp, "CONIN$", "r", stdin);
std::cout << "Console window created!" << std::endl;
}
endif
`
标签:fp,EXECUTABLE,CMAKE,QT,CLON,WIN32,freopen,控制台 From: https://www.cnblogs.com/seejv/p/18202788