Code::Blocks Forums

User forums => Help => Topic started by: chessguy on January 09, 2012, 12:05:55 am

Title: New to code blocks - compiling and decompiling
Post by: chessguy on January 09, 2012, 12:05:55 am
Greetings all. Ok, here is my story. I have slight background programming expierience. However, I am new to the need to have a compiler/debugger/IDE. IT is all a bit of a mess for me. I don't know much in terms of anything right now, but I am currently learning C++. Meaning, I need, at least, to be able to test run (debug) programs. I have no clue on how to compile them either, but I assume it'd be the same problem. I'd be glad to know the ins and outs of using it, but right now I just want to learn and get it to work. Right now, it seems a bit more than I need. All I really want is debugging, compiling... color-coding is useful however. Thus, I found my way to an IDE.

Long story short, I installed everything - basic stuff, othe rplugins, MinGW, etc. When I try to debug (start), it says... it isn't set. Go to toolchain exutables, etc. I did. I couldn't ifnd, however, which debug program you are supposedf to link to, or decompiler. Which makes it kind of useless currently.

Can anyone help me get started with this? It is a bit frustrating currently.
Thanks.
Title: Re: New to code blocks - compiling and decompiling
Post by: stahta01 on January 09, 2012, 02:02:15 am
What is the name and version of your Compiler?

Tim S.
Title: Re: New to code blocks - compiling and decompiling
Post by: chessguy on January 09, 2012, 02:22:56 am
Thanks for replying.

As per compiler, none, really. I installed code blocks and the Min GW compilers and that stuff, if it helps. Not that I k now much about that, though.

Title: Re: New to code blocks - compiling and decompiling
Post by: Alpha on January 09, 2012, 11:35:07 pm
I think you should start by reading up on your terms:

Then read the relevant parts of Installing a supported compiler (http://wiki.codeblocks.org/index.php?title=Installing_a_supported_compiler) (pay special attention to Compiler-neutral setup steps (http://wiki.codeblocks.org/index.php?title=Installing_a_supported_compiler#Compiler-neutral_setup_steps)).

And finally:

If you are still unable to get it to work, post another question here (hopefully the above reading will enable you to find more specifications).
Title: Re: New to code blocks - compiling and decompiling
Post by: chessguy on January 10, 2012, 01:20:39 am
I read up on all of those articles, actually. Except on linking. I wasn't sure if linking or decompiling were part of debugging... for instance, MinGW has the debug program gdb.exe. I was a bit confused on the matter...

When I do auto detect, it switches to:

C:\Program Files\Microsoft Visual Studio 8\VC

Which is interesting... I tried to install visual studio but it failed. Unless, that is the installer. Either way. Hm.

Currently, The code blocks folder (and thus, MinGW within) are located directly on c:\

c:\Code Blocks, etc.

That is about all I know, currently. If I make a new project, edit the main.cpp, and trydebug > start, I get:


Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: C:\Programming\y\
Adding source dir: C:\Programming\y\
Adding file: bin\Debug\y.exe
Starting debugger:
failed


also, win a single file (not a project), there is no color coding , and in the debug start is grayed out. I am not very used to using multiple files for one .exe, (though I am sure I will learn that soon), and this is wh y the term of projects and th elike are a bit confusing for me. Is this significant?



PS: While I was making a new project to debug and get the above, C:B crashed. Mabye I am cursedd...
Title: Re: New to code blocks - compiling and decompiling
Post by: Alpha on January 10, 2012, 05:33:05 am
When I do auto detect, it switches to:

C:\Program Files\Microsoft Visual Studio 8\VC
[...]
Currently, The code blocks folder (and thus, MinGW within) are located directly on c:\
Go to Settings->Compiler and debugger... and select "GNU GCC Compiler" from the drop-down menu at the top.
Now use auto detect.
Title: Re: New to code blocks - compiling and decompiling
Post by: chessguy on January 10, 2012, 03:19:19 pm
Ah... that did something. I had had it on that, but it was when I typed it (looked the same, though) because it always seemed to revert back. Now, when I debug, it actually tells me if and where I did something wrong, very useful. However... and, for learning purposes, I am working on consoles.

I know that, when they are done exuciting, it will close. However, I want to see the program output. I added a part ot it which would, in theory, make it wait for the input of the user using cin, but it just opens and closes still. Like this:

 #include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
int x;
cin >> x;
cout << x << endl;
}

I realize that is more of a code thing, but in the debugger I used before, this would make it wait, so I am wondering...

Also, - I haven't compiled anything yet... it no longer gives errors when I do it, but trying "build", "run", build AND run, etc, don't seem to have effect. Bit confused. I should probbably read up on that article a bit more now that it has a chance of working, though.

THanks.
Title: Re: New to code blocks - compiling and decompiling
Post by: Alpha on January 10, 2012, 11:40:22 pm
Yes, pausing to see what happened is nice :).

The problem with your method is that your program exits as soon as it reaches return 0; (it never reaches your other statements).
I normally pause with:
Code
#include <iostream>

using namespace std;

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

    cout << "Press enter to close program"; //Let the user know the program is done.
    cin.sync(); //Clear the buffer (just in case).
    cin.get();  //Wait for the enter key.
    return 0;   //Exit the program.
}
Title: Re: New to code blocks - compiling and decompiling
Post by: MortenMacFly on January 11, 2012, 07:51:41 am
Locking topic now,.

We are not a "Teaching C++" forum. Try a more appropriate forums for such questions, please understand.