New to C++, need help

This is a discussion on New to C++, need help within the C++ Programming forums, part of the General Programming Boards category; I just picked up a rather lengthy tutorial book on learning C++, it recommends Codeblocks, and i have installed Codeblocks ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    10

    New to C++, need help

    I just picked up a rather lengthy tutorial book on learning C++, it recommends Codeblocks, and i have installed Codeblocks 8.02
    On my first project I received the error

    "Title - Debug" uses an invalid compiler. Skipping...
    Nothing to be done.

    I have a large list of compilers to choose from, but I really have no idea what I'm doing. I've looked at other threads on the exact same issue, but they dealt with things that I've never even heard of, so if someone can explain for me what to do in simple terms I would greatly appreciate it. If it helps I'm running Win 7 64.

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,673
    >>i have installed Codeblocks 8.02

    Fair enough, where did you get it from? The code::blocks web site actually offers an updated version now, and there are two downloads: one download is just the IDE and the other offers an IDE and an older MinGW version. It sounds like you don't have a compiler at all or that code::blocks is configured to use one that you do not have. So you need to install a compiler or at least discover which one you actually have and then select that compiler from Settings -> Compiler and debugger...

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    10
    thank you whiteflags, I installed code::blocks off of a CD that came with the book, it would probably be a good idea to install it from the website.
    Is there a favored compiler for the program? or just favored by the community?

  4. #4
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,673
    Not really, just pick one that you can get from the list.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Location
    vancouver wa
    Posts
    221
    You could get visual studio IMHO its far better than code blocks. I have been using VS for awhile now.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,505
    @kdufa, when you D/L Codeblocks off the site (for the first time), make sure you get the larger package with "mingw" in the filename.

    The larger file is the IDE and the compiler (you need both).
    The smaller one is the IDE by itself, which is handy if you just want to upgrade the IDE (which is being developed).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Feb 2011
    Posts
    10
    Quote Originally Posted by Salem View Post
    @kdufa, when you D/L Codeblocks off the site (for the first time), make sure you get the larger package with "mingw" in the filename.

    The larger file is the IDE and the compiler (you need both).
    The smaller one is the IDE by itself, which is handy if you just want to upgrade the IDE (which is being developed).
    thanks salem, i already did this, but still encountered a problem
    i think i need to install mingw to C:/MinGW, instead of C:/Codeblocks, I saw that on another forum.
    i think my 'toolpath executable' is wrong, but i'm not sure on how to fix it. ill start out with that ^

  8. #8
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,673
    i think i need to install mingw to C:/MinGW, instead of C:/Codeblocks, I saw that on another forum.
    It should honestly make no difference. If you have MinGW installed, go to Settings -> Compiler and Debugger, click "Reset defaults" and see if code::blocks detects it. If it doesn't for some reason then you could always point it in the right direction by changing the path in the "Toolchain executables" tab.

  9. #9
    Registered User
    Join Date
    Feb 2011
    Posts
    10
    alright, my compiler is working but i have no idea what's going on, i select the project entitled "console application" which already has code written on it, it looks like this

    #include <iostream>

    using namespace std;

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

    and when i press build, it comes back with 6 errors..this book is telling me i should have 0 errors and 0 warnings.. i didn't even type anything in, what am i doing wrong? i installed MinGW and it is responding now

  10. #10
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,673
    What do the errors say?

  11. #11
    Registered User
    Join Date
    Feb 2011
    Posts
    10
    ||=== agureurigwe, Debug ===|
    obj\Debug\main.o||In function `main':|
    C:\Program Files (x86)\CodeBlocks\ProjectsHere\agureurigwe\main.cpp |7|undefined reference to `std::cout'|
    C:\Program Files (x86)\CodeBlocks\ProjectsHere\agureurigwe\main.cpp |7|undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'|
    C:\Program Files (x86)\CodeBlocks\ProjectsHere\agureurigwe\main.cpp |7|undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'|
    C:\Program Files (x86)\CodeBlocks\ProjectsHere\agureurigwe\main.cpp |7|undefined reference to `std:stream:perator<<(std:stream& (*)(std:stream&))'|
    obj\Debug\main.o||In function `_tcf_0':|
    c:\mingw\bin\..\lib\gcc\mingw32\4.5.2\include\c++\ iostream|73|undefined reference to `std::ios_base::Init::~Init()'|
    obj\Debug\main.o||In function `_static_initialization_and_destruction_0':|
    c:\mingw\bin\..\lib\gcc\mingw32\4.5.2\include\c++\ iostream|73|undefined reference to `std::ios_base::Init::Init()'|
    ||=== Build finished: 6 errors, 0 warnings ===|

    agrurueruaier, being the title of my project, just because it's not worth the time to put in a decent title if it's not working

  12. #12
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,673
    I need you to do me a favor then.

    Go to Compiler and debugger settings again. This time, on the compiler settings tab, click Other options. That will take you to a page where you can type in any options you want. Type "--verbose". Then click the Other settings tab. For compiler logging, select "Full command line."

    Rebuild the project from THIS thread and copy everything in the build log window into a text file just like I did.

    That will give me much more information about how, and with what programs you are actually building. I have a couple of ideas what could be wrong, but even if I can't help, with that information available, someone is bound to know what is going on with your tools.
    Attached Files Attached Files
    Last edited by whiteflags; 03-01-2011 at 03:52 PM.

  13. #13
    Registered User
    Join Date
    Feb 2011
    Posts
    10
    sorry once again,
    I followed your instructions, and hopefully this text file can tell you more.
    Attached Files Attached Files

  14. #14
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,673
    You're compiling with gcc which is one of the things I thought was happening.

    If you are using C++, then please make sure you start a C++ project. The difference is that code::blocks will then invoke g++ which links the standard library by itself. When you use gcc you have to use the command -lstdc++ to link correctly.

    Honestly I would just erase all your projects and create a new C++ one. And make sure that you actually have g++.exe in your toolchain too.

  15. #15
    Registered User
    Join Date
    Feb 2011
    Posts
    10
    thank you , I do open the new projects as C++, but I can see how that would be a problem, I'll just link my toolchain to g++ and see how it goes.

    edit: it works now! thank you for helping me
    Last edited by kdufa; 03-02-2011 at 12:17 PM.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21