Computer Science Canada SDL2 console output |
Author: | Raknarg [ Wed May 06, 2015 3:37 pm ] |
Post subject: | SDL2 console output |
Alright so I'm trying to learn how to use SDL2. I'm using a text editor and command line for it, following LazyFoo's tutorials. However, I'm trying now to introduce SDL_image into the program, and it's crashing now. However I can't figure out where it is crashing, because I can't output anything to console. I've tried reading up on it and apparently it's supposed to redirect stdout to a file, but I can't find such a file anywhere. You guys have any ideas? |
Author: | DemonWasp [ Thu May 07, 2015 8:57 am ] |
Post subject: | RE:SDL2 console output |
I took a (very brief) look at LazyFoo's tutorials and I'm not seeing anything about redirecting console output. What does your build environment look like (OS, compiler, etc)? How are you compiling and running your program? |
Author: | Raknarg [ Thu May 07, 2015 9:00 am ] |
Post subject: | RE:SDL2 console output |
He never mentions console output redirection because I guess for him it's not a problem, but for me i can't get any output anywhere, at keast none that I can tell. I'm using the makefile suggested, windows 8, using mingw with g++ |
Author: | DemonWasp [ Thu May 07, 2015 4:36 pm ] |
Post subject: | RE:SDL2 console output |
If you're just running the program from a terminal (CMD) then you should just see output from cout or printf() automatically -- by default it goes to the console. Can you post your code and the exact steps that you're using to run your program? |
Author: | Raknarg [ Sat May 09, 2015 12:52 am ] | ||||
Post subject: | RE:SDL2 console output | ||||
This is my code:
This is my makefile:
|
Author: | Raknarg [ Sat May 09, 2015 12:53 am ] |
Post subject: | RE:SDL2 console output |
Note that both SDL and SDL_image are in the same lib and include folders, I figured they should be together anyways cause they're more or less part of the same program and don't have names that match up anywhere Also those freeopen lines there are from me trying out some solutions I found online, idk if they're doing anything |
Author: | DemonWasp [ Sat May 09, 2015 8:43 am ] | ||
Post subject: | RE:SDL2 console output | ||
Output redirection happens here:
That will redirect stdout (cout) to a file called "CON". The reason you don't see that file is that Windows reserves dozens of filenames and 'con' is one of them. See this: http://superuser.com/questions/86999/unable-to-rename-a-folder-or-a-file-as-con I bet if you comment out those lines, you will suddenly have console output. |
Author: | Raknarg [ Sat May 09, 2015 11:21 am ] |
Post subject: | RE:SDL2 console output |
Tbats what my second comment was for. I was trying that out because it wasn't working. Evem without those lines it doesn't work. |
Author: | DemonWasp [ Sat May 09, 2015 12:56 pm ] |
Post subject: | RE:SDL2 console output |
I don't have an environment where I can build SDL2, so my only suggestion now is to start removing stuff. If you comment out everything in main() except the printf() statement, recompile and rerun, do you at least see HI in the cmd prompt? |
Author: | Raknarg [ Sat May 09, 2015 1:19 pm ] |
Post subject: | RE:SDL2 console output |
think I just figured it out. This line on my makefile: -Wl,-subsystem,windows Got rid of that and now it gives me console output |
Author: | DemonWasp [ Sat May 09, 2015 7:50 pm ] |
Post subject: | RE:SDL2 console output |
Interesting. Apparently -Wl is used to pass arguments to the linker. In this case, you're passing --subsystem windows , which apparently tells the linker to (somehow) omit console output. That's pretty weird. Usually programs have console output even if they also have a GUI -- it's usually just hidden. |
Author: | Raknarg [ Sat May 09, 2015 9:30 pm ] |
Post subject: | RE:SDL2 console output |
Interesting. Of course now I have to figure out why SDL_image os crashing in the first place, but it's a start |