Author Topic: New to code blocks - compiling and decompiling  (Read 8827 times)

Offline chessguy

  • Single posting newcomer
  • *
  • Posts: 4
New to code blocks - compiling and decompiling
« 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.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: New to code blocks - compiling and decompiling
« Reply #1 on: January 09, 2012, 02:02:15 am »
What is the name and version of your Compiler?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline chessguy

  • Single posting newcomer
  • *
  • Posts: 4
Re: New to code blocks - compiling and decompiling
« Reply #2 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.


Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: New to code blocks - compiling and decompiling
« Reply #3 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 (pay special attention to 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).

Offline chessguy

  • Single posting newcomer
  • *
  • Posts: 4
Re: New to code blocks - compiling and decompiling
« Reply #4 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...
« Last Edit: January 10, 2012, 01:23:10 am by chessguy »

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: New to code blocks - compiling and decompiling
« Reply #5 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.

Offline chessguy

  • Single posting newcomer
  • *
  • Posts: 4
Re: New to code blocks - compiling and decompiling
« Reply #6 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.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: New to code blocks - compiling and decompiling
« Reply #7 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.
}

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: New to code blocks - compiling and decompiling
« Reply #8 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ