Reputation: 33
I had linker error: undefined reference to windows.h functions like textout,selectobject,beginpaint. But I was able to remove the error
by adding "-mwindows"
in sublime build system. But now im not able to get any output in windows terminal. Eg: if i try to use printf("test");
it won't show any output in windows terminal and textout()
will only output textout string in gui window.
I tried it with codeblocks and it was able to get output of printf in windows terminal and textout in another window.
Is there anyway i can make sublime build system do the same?
{
"cmd": ["gcc", "-Wall","-mwindows","-pedantic-errors", "$file_name","-o", "${file_base_name}.exe", "&&", "start", "cmd", "/k" , "$file_base_name"],
"selector": "source.c",
"working_dir": "${file_path}",
"shell": true
}
Upvotes: 0
Views: 183
Reputation: 244843
If you want to build a console application, then you need to also add the -mconsole
option to your compiler command line.
That will give you a Windows application that automatically creates and runs in the context of a console (text-based environment).
If you just pass -mwindows
, then you get a standard Windows application that expects to have a GUI. You (your code) is responsible for creating a window and outputting text/graphics to that window. It doesn't happen automatically.
Upvotes: 2