[Dev-C++] Newbie linking errors: 'undefined reference'
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: David M. <ci...@ya...> - 2002-02-10 10:46:36
|
Undefined reference means that the linker cannot find the function you are talking about a compiler does not have to worry about stuff like that the only time I get a error like that is when I forget to link with whatever library I am using(for now that is Allegro most of the time) make sure the function is visible from wherever you are calling it you may have to use an extern keyword (sorry but I don't know how to use it, my projects have not gotten that big) I have not gotten as far as the STL but I am told not to use Dev-C++'s makefiles >Message: 6 >From: "Devin Carless" <dcc...@ya...> >To: <dev...@li...> >Date: Sat, 9 Feb 2002 14:47:28 -0500 >Subject: [Dev-C++] Newbie linking errors: 'undefined reference' > > > Generally, I like to lurk and listen a bit before I post, but this >time I'm really at wit's end. > > My project, a simple game based on the old Lost Worlds >booklets, keeps generating undefined reference errors in the >linking stage. They look like this: > >d:/devin/projects/lostworlds/womanqsprototype.o(.data$_vt$11WomanQSBook+0x5c >):womanqsprototy: undefined reference to `BaseBook::Lookup(unsigned short, >unsigned short) const' > > The compiler had no problems with just such a function, but >the linker does. (I'm using Dev-C++ 4 with MinGW 2.95.2, >with the -v -H flags for the linker.) I don't know what >'undefined reference' means, and nowhere on the Net (that Google >can find) is there a document that tells me, either. > Sometimes I can temporarily make them go away with cosmetic >changes to the code: moving a function definition from the .cpp to >the .h, moving a function declaration in the .h, etc., seems to work >for individual errors. But whenever I add a new module they >come back again, twice as plentiful. > > I thought it might be STL and vectors, but changing my >container implementation to use arrays didn't help. So it's not, as >I thought, STL's fault. It might be a link order problem, so I >used the Make Makefile function and tried to do things from the >command line. However, I can't get make to work with the >Dev-C++'s makefiles: it gives me errors like '**18: Multiple >targets.' And Dev-C++'s Project Options only asks for >-additional- arguments to pass to the linker. > So I'm really getting demoralized. This problem has held me >up for three days now. I'd very much appreciate some assistance. > > It has been suggested I provide a code fragment, but since the >errors seem to be independent of legality of the code, and only >crop up when the projects gets big, I don't see how it would help. >However, I will provide such a thing if asked, though I really have >no idea what could be relevant to the problem. > >--Devin Carless |