HEllo there!
I'm a total newbie to C++ programing. After taking the very first lesson (creating the famous "hello world!" message on the screen), the executable runs so fast that I can't even see the command line window before it dissappears. I've already read the FAQ No.2 that says:
"2. When executing my dos program, it closes automatically. How I can change this ?
You can use an input function at the end of you source, like the following example :
include <stdlib.h>
int main()
{
system(PAUSE);
return 0;
}
"
but the result is exactly the same as before?! IS there a sloution to this?
P.S. I'm using Windows XP Pro
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Probably not something you need to worry too much about at this point, but there should be a section on Compiler Options in Dev's Help. You can see for yourself how changes show up in the compile log....
-- Jim.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
HEllo there!
I'm a total newbie to C++ programing. After taking the very first lesson (creating the famous "hello world!" message on the screen), the executable runs so fast that I can't even see the command line window before it dissappears. I've already read the FAQ No.2 that says:
"2. When executing my dos program, it closes automatically. How I can change this ?
You can use an input function at the end of you source, like the following example :
include <stdlib.h>
int main()
{
system(PAUSE);
return 0;
}
"
but the result is exactly the same as before?! IS there a sloution to this?
P.S. I'm using Windows XP Pro
Hi Wayne!
I am using Dev-C++ 4.9.9.0 on a Windows XP Pro machine. Here's my code and the content of my compiler log:
include<iostream>
include<stdlib.h> //only needed if you are using Dev 4 family
using namespace std; //where the names are - like cout!
int main(void)
{
cout << "This is what that putz Wayne said to do!\n";
system("pause"); //keep the window open if running from Dev
return 0;
}
Compiler: Default compiler
Executing g++.exe...
g++.exe "E:\Dev-Cpp\Moji prvi pokusaji\Untitled1.cpp" -o "E:\Dev-Cpp\Moji prvi pokusaji\Untitled1.exe" -g3 -nostdlib -I"e:\Dev-Cpp\include\c++\3.3.1" -I"e:\Dev-Cpp\include\c++\3.3.1\mingw32" -I"e:\Dev-Cpp\include\c++\3.3.1\backward" -I"e:\Dev-Cpp\lib\gcc-lib\mingw32\3.3.1\include" -I"e:\Dev-Cpp\include" -L"e:\Dev-Cpp\lib" -lobjc -g3 -nostdlib -s
e:\Dev-Cpp\Bin..\lib\gcc-lib\mingw32\3.3.1........\mingw32\bin\ld.exe: warning: cannot find entry symbol _mainCRTStartup; defaulting to 00401000
C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x45): In function
main': E:/Dev-Cpp/Moji prvi pokusaji/Untitled1.cpp:6: undefined reference to_alloca'C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x4a):E:/Dev-Cpp/Moji prvi pokusaji/Untitled1.cpp:6: undefined reference to
__main' C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x59):E:/Dev-Cpp/Moji prvi pokusaji/Untitled1.cpp:7: undefined reference tostd::cout'C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x5e):E:/Dev-Cpp/Moji prvi pokusaji/Untitled1.cpp:7: undefined reference to
std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x6a):E:/Dev-Cpp/Moji prvi pokusaji/Untitled1.cpp:8: undefined reference tosystem'C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x93): In function
Z41__static_initialization_and_destruction_0ii': e:/Dev-Cpp/include/c++/3.3.1/iostream:77: undefined reference tostd::ios_base::Init::Init()'C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0xae):e:/Dev-Cpp/include/c++/3.3.1/iostream:77: undefined reference to `std::ios_base::Init::~Init()'
Execution terminated
Please help!!!
Try this: Tools > Compiler > Settings. From there, set everything to No (blank for machine/processor settings).
It is best not to play with those settings unless/until you know what they are supposed to do....
-- Jim.
Thanks, Jim!
It's working properly now, although I must admit that I still don't know why!
Goran
Probably not something you need to worry too much about at this point, but there should be a section on Compiler Options in Dev's Help. You can see for yourself how changes show up in the compile log....
-- Jim.
Why it does not work might be the following compile option:
-nostdlib
Which explicitly turns off the C++ standard library stuff, which you are using.
Wayne
I does appear that this thread was hijacked, I don't think the question that was answered was the one originally posted.
Wayne
Post your full compile log, I suspect you are compiling a windows executable rather than a console one.
Wayne
In case there could be be any confusion, make that:
Tools > Compiler Options > Settings
-- Jim.