CapsCollective / raylib-cpp-starter

A portable, automated template for raylib projects with C++ bindings
Other
68 stars 17 forks source link

Cannot see print statements in terminal #12

Closed DarkKnight2000 closed 2 years ago

DarkKnight2000 commented 2 years ago

Hey! Thanks for the great starter project. I was able to run make setup and make without any problems. But after running the app, I couldn't see any print statements ( the extra info that raylib prints ). Even if I write cout << they are not printed.

Screenshot (1805)

I am on Windows 10 and cloned the repo just a few hours back. I am building raylib in DEBUG mode and added an extra flag to not compile Raylib audio ( Some conflicts with windows.h at CloseWindow() ) so added these flags on line 77. These are the only changes I did.

Screenshot (1806)

I think I am missing some small thing here but can't figure out what. Any help is appreciated, Thanks!

jonjondev commented 2 years ago

No worries @DarkKnight2000, it's a common issue with non-VS, Windows executables you have there.

Basically, Windows requires extra steps to pipe output to the parent process and can be added to this project as so:

#include <raylib-cpp.hpp>
#include <windows.h>

int main() {
    // Attach Windows console
    AttachConsole(ATTACH_PARENT_PROCESS);
    freopen("CON", "w", stdout);
    freopen("CON", "w", stderr);
    freopen("CON", "r", stdin);

    // the rest of your main function....
}

You can see a previous thread about it here https://github.com/CapsCollective/vulkan-cpp-starter/issues/5. I hope this resolves the issue for you!

DarkKnight2000 commented 2 years ago

Hey, Thanks for the reply, that works like a charm!! I had to write typedef struct tagMSG *LPMSG; before #include <windows.h> and its compiling! Thanks!