Author Topic: Trying to Run Hello World in Debug mode  (Read 9949 times)

Offline Ed997

  • Multiple posting newcomer
  • *
  • Posts: 12
Trying to Run Hello World in Debug mode
« on: December 25, 2008, 08:02:49 pm »
12-45 pm  12-25-08


  Hi,

    I am just getting started with C++ and I just ran from problems in Visual Studio Express 2008 C++.

I am into scripting, but wanted to start to learn C++.

CodeBlocks looks like the answer for me w/MinGW.

I have a project "Hello World". When I try to run in the debug mode, I get:

Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Release
Adding source dir: C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\C++ CodeBlocks\Hello World\
Adding source dir: C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\C++ CodeBlocks\Hello World\
Adding file: bin\Release\Hello World.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
(no debugging symbols found)
Debugger name and version: GNU gdb 6.7.50.20071127
No symbol table is loaded.  Use the "file" command.
Error creating process C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\C++ CodeBlocks\Hello World/bin/Release/Hello World.exe, (error 193).

I can compile and run in the release mode without errors.

My simple .cpp file is:

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    cout << "CodeBlocks is working !!!!!" << endl;

    char myLine[100];
   std::cin.getline(myLine,100);
    return 0;
}

If someone could help give me a leg up with this basic issue, I would be off and running.

I am sure there is something basic, I do not understand.

Thanks, Ed



Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Re: Trying to Run Hello World in Debug mode
« Reply #1 on: December 26, 2008, 09:28:06 am »
Move the whole project to a path without ++ in it and try again. If that doesn't work, then I have no idea what it could be.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5214
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Trying to Run Hello World in Debug mode
« Reply #2 on: December 27, 2008, 07:01:04 am »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Ed997

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Trying to Run Hello World in Debug mode
« Reply #3 on: December 29, 2008, 06:20:20 pm »
11-06 am  12-29-08

   Hi,

   I checked out the .swf video. omg it is Soo small!, I cannot read the text and their is no audio to follow! I would like to see/understand your work !

  How could I get a larger copy!

  Thanks, Ed




Offline Ed997

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Trying to Run Hello World in Debug mode
« Reply #4 on: December 29, 2008, 06:27:22 pm »
11-09 am  12-29-08

   Ceniza,

  I have my project in a remote folder location, and not in the Codeblocks directory of Program Files. If that is what you mean.
But you could see that from my Absolute Filepath in my post, so I am not sure I understand your reply.

  I will eventually solve this on my own (I have so infrequently (almost never) gotten help in forums, though I have posted in many often enough to say this).

  When I do, (working on this as time permits) I will post the answer to my Post.

  Thanks, Ed

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Trying to Run Hello World in Debug mode
« Reply #5 on: December 29, 2008, 07:52:40 pm »
Ceniza means what he says: a path without "++" in it.

But I don't think that's the problem.

Error 193 means "ERROR_BAD_EXE_FORMAT".

Is it possible to run your exe from commandline ?
Start a console change directory to where the exe is and run it.
Try to run it with gdb also.

It would probably help if you turn on the debugger's debug log (goto "Settings -> Compiler and debugger... -> Debugger settings" and check "Display debuggers's log") and post it.

Do you have multiple gdb's on your system ?
You should use the MinGW-gdb with MinGW compiled code.


Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5214
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Trying to Run Hello World in Debug mode
« Reply #6 on: December 30, 2008, 03:39:05 am »
11-06 am  12-29-08

   Hi,

   I checked out the .swf video. omg it is Soo small!, I cannot read the text and their is no audio to follow! I would like to see/understand your work !

  How could I get a larger copy!

  Thanks, Ed





Yes, you can't copy the test in swf. And I haven't record audio. There is no larger copy. :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Ed997

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Trying to Run Hello World in Debug mode
« Reply #7 on: December 30, 2008, 06:09:27 pm »
10-48 am  12-30-08

   Hi Jens,

   I neglected to mention that if I went to Hello World\bin\Debug\  .... I can double click the Hello World.exe file and it runs fine.

This confused me as according to CodeBlocks there was an error creating it.


==========================================================================
I ran for a debug build again after enabling the debugger log, here is what I got:

PATH=.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\WINDOWS;C:\Program Files\CodeBlocks\MinGW\bin;C:\borland\BCC55\bin\;C:\Borland\BCC55\Include\;C:\Borland\BCC55\Lib\;C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\;C:\Program Files\Microsoft Visual Studio 9.0\VC\bin;C:\WINDOWS\System32\Wbem\;C:\Program Files\QuickTime\QTSystem\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\Common Files\GTK\2.0\bin;C:\PROGRA~1\XSoft;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\AutoIt3;C:\PROGRA~1\DISKEE~1\DISKEE~1\
Command-line: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname  -quiet -args "bin/Debug/Hello World.exe"
Working dir : C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\C++ CodeBlocks\Hello World\
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.7.50.20071127
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set debugevents on
>>>>>>cb_gdb:
> set new-console on
>>>>>>cb_gdb:
> set disassembly-flavor att
>>>>>>cb_gdb:
> directory C:/DOCUME~1/ED/Desktop/TEXTNO~1/C__COD~1/HELLOW~1/
>>>>>>cb_gdb:
> run
Error creating process C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\C++ CodeBlocks\Hello World/bin/Debug/Hello World.exe, (error 193).
gdb: win32_init_thread_list
>>>>>>cb_gdb:


====================================================

What do you think? I did a search in \Program Files\CodeBlocks\MinGW and there is only one gdb.exe in the "C:\Program Files\CodeBlocks\MinGW\bin" Folder.

Thanks in advance, Ed
« Last Edit: December 30, 2008, 06:15:34 pm by Ed997 »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Trying to Run Hello World in Debug mode
« Reply #8 on: December 30, 2008, 10:16:37 pm »
Can you change "Settings -> Compiler and debugger... -> Global compiler Settings -> [the compiler you use for the project] -> Other settings (the rightmost tab) -> Compiler logging" to "Full commandline", do a rebuild  and post the build log ?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5214
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Trying to Run Hello World in Debug mode
« Reply #9 on: December 31, 2008, 03:17:35 am »
Quote
Error creating process C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\C++ CodeBlocks\Hello World/bin/Debug/Hello World.exe, (error 193).

Your folder seems too long. Change it to a simple folder name with out "spaces".
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Trying to Run Hello World in Debug mode
« Reply #10 on: December 31, 2008, 10:35:04 am »
Quote
Error creating process C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\C++ CodeBlocks\Hello World/bin/Debug/Hello World.exe, (error 193).

Your folder seems too long. Change it to a simple folder name with out "spaces".

I have tried it with exactly the same path (for project and executables) and the same gdb version on w2k and it works.

Offline Ed997

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Trying to Run Hello World in Debug mode
« Reply #11 on: December 31, 2008, 06:28:32 pm »
Can you change "Settings -> Compiler and debugger... -> Global compiler Settings -> [the compiler you use for the project] -> Other settings (the rightmost tab) -> Compiler logging" to "Full commandline", do a rebuild  and post the build log ?

  Jens,

   Ok, I did exactly that, Build Log:

-------------- Build: Debug in Hello World1 ---------------

mingw32-g++.exe -Wall -fexceptions  -Wall -g  -Wall -g    -c "C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\C++ CodeBlocks\Hello World1\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe  -o "bin\Debug\Hello World1.exe" obj\Debug\main.o   
Output size is 595.10 KB
Process terminated with status 0 (0 minutes, 9 seconds)
0 errors, 0 warnings


Regards, Ed



Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Trying to Run Hello World in Debug mode
« Reply #12 on: December 31, 2008, 06:49:19 pm »
The build log looks okay, except for the amount of "-Wall -g".

I have no clue what happens.

The only thing to test would be to use a a shorter path (if possible one that only contains standard-ascii characters without spaces) for new wizard-created project.

You don't need to change the wizards-settings for the console-application, unless you definitely need other options (that would avoid the multiple "-Wall -g").

Offline Ed997

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Trying to Run Hello World in Debug mode
« Reply #13 on: December 31, 2008, 07:21:14 pm »
Quote
Error creating process C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\C++ CodeBlocks\Hello World/bin/Debug/Hello World.exe, (error 193).

Your folder seems too long. Change it to a simple folder name with out "spaces".

Olldbg and Jens,

Ok, Wanting to Double Check all leads, I thought "though the 'Absolute Path filename' may have been OK on Jens computer setup. ....., maybe it is not on mine.

   Since I have run into file-lenght problems before in other editing/scripting.


   Made "New Project from scratch, adding in the same .cpp file.

I made my project as  "C:\0\HiWorld". [I do not believe (but will prove) the lack of spaces in the name is important].

   Once I constructed the project I :   Debug / Start.


========== Build Log ==========================
-------------- Build: Debug in HiWorld ---------------

mingw32-g++.exe -Wall -fexceptions  -g  -Wall -g    -c C:\0\HiWorld\HiWorld.cpp -o obj\Debug\HiWorld.o
mingw32-g++.exe  -o bin\Debug\HiWorld.exe obj\Debug\HiWorld.o   
Output size is 595.10 KB
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 0 warnings
 
==========================================

=========== Debug Log ==============================
PATH=.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\WINDOWS;C:\Program Files\CodeBlocks\MinGW\bin;C:\borland\BCC55\bin\;C:\Borland\BCC55\Include\;C:\Borland\BCC55\Lib\;C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\;C:\Program Files\Microsoft Visual Studio 9.0\VC\bin;C:\WINDOWS\System32\Wbem\;C:\Program Files\QuickTime\QTSystem\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\Common Files\GTK\2.0\bin;C:\PROGRA~1\XSoft;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\AutoIt3;C:\PROGRA~1\DISKEE~1\DISKEE~1\
Command-line: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname  -quiet -args bin/Debug/HiWorld.exe
Working dir : C:\0\HiWorld\
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.7.50.20071127
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set debugevents on
>>>>>>cb_gdb:
> set new-console on
>>>>>>cb_gdb:
> set disassembly-flavor att
>>>>>>cb_gdb:
> directory C:/0/HiWorld/
>>>>>>cb_gdb:
> run
gdb: win32_init_thread_list
Program exited normally.
>>>>>>cb_gdb:
> set debugevents off
>>>>>>cb_gdb:
> quit

================================================

'################################################################## 
So far So Good, Next Experiment ......... New Project ............. Proving the spaces are OK:
'################################################################## 


I made my project as  "C:\0 0 0 0\Hi World New Project".  (same .cpp file)

   Once I constructed the project I :   Debug / Start.


========== Build Log ==========================
-------------- Build: Debug in Hi World New Project ---------------

mingw32-g++.exe -Wall -fexceptions  -g  -Wall -g    -c "C:\0 0 0 0\Hi World New Project\Hi World New Project.cpp" -o "obj\Debug\Hi World New Project.o"
mingw32-g++.exe  -o "bin\Debug\Hi World New Project.exe" "obj\Debug\Hi World New Project.o"   
Output size is 595.13 KB
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 0 warnings
 
 
==========================================

=========== Debug Log ==============================
PATH=.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\WINDOWS;C:\Program Files\CodeBlocks\MinGW\bin;C:\borland\BCC55\bin\;C:\Borland\BCC55\Include\;C:\Borland\BCC55\Lib\;C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\;C:\Program Files\Microsoft Visual Studio 9.0\VC\bin;C:\WINDOWS\System32\Wbem\;C:\Program Files\QuickTime\QTSystem\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\Common Files\GTK\2.0\bin;C:\PROGRA~1\XSoft;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\AutoIt3;C:\PROGRA~1\DISKEE~1\DISKEE~1\
Command-line: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname  -quiet -args "bin/Debug/Hi World New Project.exe"
Working dir : C:\0 0 0 0\Hi World New Project\
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.7.50.20071127
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set debugevents on
>>>>>>cb_gdb:
> set new-console on
>>>>>>cb_gdb:
> set disassembly-flavor att
>>>>>>cb_gdb:
> directory C:/0000~1/HIWORL~1/
>>>>>>cb_gdb:
> run
gdb: win32_init_thread_list
Program exited with code 030000000472.
>>>>>>cb_gdb:
> set debugevents off
>>>>>>cb_gdb:
> quit

================================================

*******************************************************************
Summary:
For the moment it looks like my Absolute Path Filename was too long for my setup.
*******************************************************************

For now I think I am in great shape, to move foreward and learn.

Thank you guys very much for your quick feedback, ......and knowledgeable input.

Hopefully I can return the favor on some subject soon, for the forums.

Thanks again, and I am sure I will be bugging you soon maybe for some more legitimate problems !!!!
Regards, Ed

Offline Ed997

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Trying to Run Hello World in Debug mode
« Reply #14 on: December 31, 2008, 08:01:14 pm »
The build log looks okay, except for the amount of "-Wall -g".

I have no clue what happens.

The only thing to test would be to use a a shorter path (if possible one that only contains standard-ascii characters without spaces) for new wizard-created project.

You don't need to change the wizards-settings for the console-application, unless you definitely need other options (that would avoid the multiple "-Wall -g").

   Jens,

You can access Compiler Flags for Debug, two ways I know of:

Right click the project in the management pane and choose Build

Options. Now on the Compiler Flags Tab you can set Debug and

Release Build choices separately.

Also you can use the Settings/Global Compiler settings -- Compiler

Flags Tab. Here you are setting the Debug and Release Build

choices Both at the same time.

=====================================
To eliminate doubling up on the flags .......

With "Settings/Global Compiler settings -- Compiler Flags Tab" I

left all boxes unchecked.

Then I made my flag choices with the:
"Right click the project in the management pane and choose Build

Options", then choosing Debug mode, then making my selections.

==================================
Then in the Build Log, I see only one -Wall and one -g switch.


Jens does this make sense to you?


Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Trying to Run Hello World in Debug mode
« Reply #15 on: December 31, 2008, 09:55:11 pm »
Globally compiler settings are normally not needed,
project wide settings are good for things like "-Wall" or "-fexceptions" that are needed by all targets (for example debug and release),
the target settings are used to optimize targets, the "-g" or "-pg" switch only makes sense for the debug target, all optimization-switches ("-Ox") or "-s" only make sense for targets that are not debug targets.

Offline Ed997

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Trying to Run Hello World in Debug mode
« Reply #16 on: January 02, 2009, 10:32:47 pm »
3-17 pm  01-02-09

   Jens,

   I am afraid I was having a brain cramp and did not realize there was now a Page 2 to the thread   :oops: (and you had responded a couple days ago).

   Thanks, I will digest what you said later today and respond.   Tx much. Ed

Offline Ed997

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Trying to Run Hello World in Debug mode
« Reply #17 on: January 02, 2009, 11:43:18 pm »

4-30 pm  01-02-09

Ok, this makes sense.  Though I do not know where I am adding the

-Wall switch as no box is checked in "Settings/Compiler and

Debugger / Global Compiler Settings / Compiler Flags Tab ".

And the -wall box is not checked in either the Debug or Release

build targets ....... in Project / Build Options Compiler-Flag Tab.

But at this point -Wall is fine with me.

I guess I am done with this thread (new ones around the corner !).

Thanks .....All,

Regards, Ed

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Trying to Run Hello World in Debug mode
« Reply #18 on: January 03, 2009, 10:53:17 am »
Hi Ed,

do you think it is necessary to put a timestamp at the beginning of all your posts whereas it is already written in the post header with the right timezone ?

Dje

[attachment deleted by admin]