Author Topic: Help with using code::blocks  (Read 6396 times)

Offline blindtolive

  • Single posting newcomer
  • *
  • Posts: 3
Help with using code::blocks
« on: January 04, 2012, 11:22:02 am »
So i have just started learning C++ and i started with the hello world tutorials and that went good i got it to open no problem butnow i am trying to do the calculator like so


#include <iostream>

int add(int x, int y)
{
     // add the numbers x and y together and return the sum
     std::cout << "running calculator...\n";
     return (x+y)
}
int main()
{
/*this program calls an add() function to add two diffrent sets of numbers together and displays the results. the add() function dosnt do anything unless it is called by a line in the main() function. */
     std::cout << "what is 867 + 5309?\n";
     std::cout << "the sum is " << add(867, 5309) << "\n\n";
     std::cout << "what is 777 + 9311?\n";
     std::cout << "the sum is " << add(777, 9311) << "\n";
     return 0;
}

and it keeps opening the Hello World window when i click run on the calculator...i notice to that in my files folder it auto creates a main.cpp...i figure its something im doing wrong but i cant pinpoint it any help would be much appreciated.

thanks in advance

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Help with using code::blocks
« Reply #1 on: January 04, 2012, 02:32:56 pm »
Turn on Full Compiler Logging; then read/post the full compiler log after doing re-build of the project.

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

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

zabzonk

  • Guest
Re: Help with using code::blocks
« Reply #2 on: January 04, 2012, 02:45:51 pm »
Quote
i notice to that in my files folder it auto creates a main.cpp

Put your code in the auto-created main.cpp.

Offline blindtolive

  • Single posting newcomer
  • *
  • Posts: 3
Re: Help with using code::blocks
« Reply #3 on: January 04, 2012, 03:00:10 pm »
so i turned on full compiler logging i just wasnt 100% sure where to get the log but i hope this is right


Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: C:\Users\owner\Desktop\C++\calc\
Adding source dir: C:\Users\owner\Desktop\C++\calc\
Adding file: bin\Debug\calc.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.8
Child process PID: 6104
Program exited normally.
Debugger finished with status 0

i started from scratch and remade it and still opens the Hello World instead

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Help with using code::blocks
« Reply #4 on: January 04, 2012, 03:13:32 pm »
Please post the Build log (after turning on FULL COMPILER LOGGING) not the log you posted after you do a re-build of project.

You likely are NOT compiling the right file.

NOTE: to do a re-build choose "rebuild" from the "build" menu.

Tim S.
« Last Edit: January 04, 2012, 03:18:44 pm by stahta01 »
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 blindtolive

  • Single posting newcomer
  • *
  • Posts: 3
Re: Help with using code::blocks
« Reply #5 on: January 05, 2012, 10:45:36 am »

-------------- Clean: Debug in calc ---------------

Cleaned "calc - Debug"

-------------- Build: Debug in calc ---------------

mingw32-g++.exe -Wall -fexceptions  -g     -c C:\Users\owner\Desktop\C++\calc\main.cpp -o obj\Debug\main.o
mingw32-g++.exe  -o bin\Debug\calc.exe obj\Debug\main.o   
Output size is 913.65 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
 
i got it to work by putting the source in main.cpp that gets auto created in my calc folder like Neil Butterworth said(thank you) i still
dont know how it is being created it has the "Hello World" source code in it but anyway after i did that and fixed an error i managed to
find in the code it worked just fine thanks again :)