Thread: Dev-C++ compiler problem

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    16

    Dev-C++ compiler problem

    Dear all

    I am currently using:

    Windown XP 2002 Pro with Service Pack 2
    Dev-C++ Version 4.9.9.2

    I am new to programming and I am learning from a book call "C++ All-in-one Desk reference for dummies" by Jeff Cogswell. I tried to use the code provided to see how the language works. The book uses version 4.9.9.0. I loaded the code which is all in the same project, and i have some compiler error that i do not understand. Please help! The code and error messages are displayed below

    Code:
    
    #include <iostream>
    #include <stdlib.h>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
      int NumberOfPotholes = 532587;
      NumberOfPotholes = 6087;
      int *ptr;
      ptr = &NumberOfPotholes;
      *ptr = 6087;
      cout << NumberOfPotholes << endl;
      cout << &NumberOfPotholes << endl;
      cout << ptr << endl;
      system("PAUSE");	
      return 0;
    }
    Error Message
    cannot find -lobjc
    ld returned 1 exit status
    [Build Error] [Pointer1.exe] Error 1

    Any help is much appreaciated, I am getting a bit frustrated with programming, so if anyone knows any smarter way to learn C++, that will be great too.

    Regards

    Grasshopper Esq.

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Erm the version of Dev the book comes with is very old. And that program is quite advanced for a starting point.

    I advise getting Visual C++ 2008 Express which is free download from Microsoft website.

    -lobjc looks like an "object" or part of the run exe file that it cannot locate. I would almost certainly consider getting a better IDE/compiler for later use, as Dev is ok but its badly bugged
    Double Helix STL

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    16
    Thank you for the reply, may i ask is there much difference between using Visual C++ 2008 and using Dev-C++? I had a quick look around the web, it seem to be a problem with the compiler according to some forum. I have only just pick the language up from yesterday, so i am still quite new and not very experience. Thank you again

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Visual C++ is much larger than Dev as an IDE. It has lots of features that Dev doesnt have, but as you are just starting out, then that isnt a problem, as most of it you would never use untill you were quite experienced in the language syntax.

    I would also reomend you starting with a much simpler program, somthing like:

    Code:
    #include <iostream>
    
    int main()
    {
       std::cout << "Hello World!\n";
    
       std::cin.get();
    
       return 0;
    }
    If you can get that to work and compile, your away. And also system("pause"); is a terrible way for a book to be teaching you to hold the console open. Use cin.get() as I did above, it is much more portable and compliant.
    Double Helix STL

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    16
    Thank you so much I will try to download the Visual C++, do you know any good resource for learning this program?

  6. #6
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Don't listen to him. Dev C++ should have been able to compile that program fine. I would recommend, however, uninstalling it and downloading the latests version from blodshed.

    Of course, you could always install code::Blocks if you want something that's a bit more up to date.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  7. #7
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Thats rather rude.

    I was only offering advice which I am fully entitled to do on a forum, whether the OP chooses to take the advice is up to them.
    Double Helix STL

  8. #8
    Registered User
    Join Date
    May 2008
    Posts
    16
    I appreciated all the help, where can i install code::blocks?

  9. #9
    Registered User
    Join Date
    May 2008
    Posts
    16
    Thank you both for your help, I have tried and retyped the code, and it seems to work, i wonder if there is anything to do with the end of line character between different system. any ideas?

  10. #10
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    if you are doing everything on the same platform (coding and compiling), it shouldn't be the problem. I even occassionally code on Linux and compile and Windows and vice versa and there doesn't seem to be any problems either. I am assuming compilers (parsers) are smart enough to figure it out.

    BTW, I second Code::Blocks (google will tell you where to download). Since your book uses Dev-C++, which uses GCC as its compiler, it will probably be a good idea (at least when you are starting off) to stick with an IDE that also uses GCC (such as Code::Blocks, and not VC++, which uses Microsoft's own compiler).

  11. #11
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    although theoretically, as long as you write standard C++, any compiler will work, practically, every compiler has its own quirks.

  12. #12
    Registered User
    Join Date
    May 2008
    Posts
    16
    Well, the funny thing is, when i actually type the code in instead of cut and paste, it works! Now i am even more confuse. but i will give code::blocks a try! thanks mate

  13. #13
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    You will learn a great deal more by typing the code in yourself rather than copy/paste too.

    This is a good ideal to cling to for later learning practices. When you learn somthing new, you type it as it says in a book and may think "I wonder how this works..." as you type it. It then encourages you to dive deeper into how certain aspects and algorithms of the language work.
    Double Helix STL

  14. #14
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Though I am not quite compelled to jump on the Microsoft bandwagen, I would like to point out that Dev-C++ is seriously out of date. And to answer the original question (which no one has even bothered to take the time to do as of yet). You are actually dealing with a known issue with the MinGW compiler on Windoze Vi$ta. What you need to do is edit your path to include the folders which contain gcc (and mingw32-gcc) as well as c1, and ld. Using the crappy vista search tool will likely not find any of these files since m$ has a very buggy file indexing system in all of its current OSes. You are looking for folders something like C:\MinGW\bin and C:\MinGW\libexec\gcc\mingw32\3.4.5 (or whatever version... this is what mine is set to atm anyway).

    Good luck.

  15. #15
    Registered User
    Join Date
    May 2008
    Posts
    24
    I'm taking a C++ class and they recommend Dev C++ for beginners because it's easier to use than Visual C++ and more user friendly.
    Last edited by slimdime; 05-03-2008 at 09:11 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird compiler (Dev)
    By gavra in forum C Programming
    Replies: 11
    Last Post: 08-03-2008, 01:19 AM
  2. Starting with Dev C ; a problem
    By mabauti in forum C++ Programming
    Replies: 18
    Last Post: 12-05-2007, 11:16 AM
  3. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  4. Dev C++ Compiler - True or false?
    By JamesF in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 07-10-2006, 11:03 AM
  5. Comile problem using latest Dev C++ Compiler
    By shiny_dico_ball in forum C++ Programming
    Replies: 6
    Last Post: 06-06-2003, 05:32 PM