-
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.
-
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
-
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
-
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.
-
Thank you so much I will try to download the Visual C++, do you know any good resource for learning this program?
-
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.
-
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.
-
I appreciated all the help, where can i install code::blocks?
-
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?
-
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).
-
although theoretically, as long as you write standard C++, any compiler will work, practically, every compiler has its own quirks.
-
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
-
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.
-
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.
-
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.