1,105,391 Community Members

Dev C++ linker errors, undefined reference

Member Avatar
Asif_NSU
Posting Whiz
353 posts since Apr 2004
Reputation Points: 25 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

You may want to investigate makefiles. Then you can use your favorite editor and still write modular code the correct way.

I just had a glance at how to write makefiles. Looks messy(will look into that later). So opened Dev C++ instead, and tried to work with projects for the first time in DevC++( used visual C++ projects bfor though). The program compiles without error but i get errors while linking, saying undefined reference to xyz. Obviously the linker is not finding the definitions of the declared functions. I did include the .cpp files containing the definitions in my project, but still getting the same errors. What should i do?

Member Avatar
Narue
Bad Cop
12,139 posts since Sep 2004
Reputation Points: 5,693 [?]
Q&As Helped to Solve: 1,537 [?]
Skill Endorsements: 81 [?]
Team Colleague
 
0
 

>What should i do?
Post a reply to the thread that this question is concerning rather than starting a new one so that we have a clue what you're talking about. ;)

Member Avatar
Dave Sinkula
long time no c
4,852 posts since Apr 2004
Reputation Points: 2,398 [?]
Q&As Helped to Solve: 340 [?]
Skill Endorsements: 69 [?]
Team Colleague
 
0
 

I can't see your computer, but it sounds like you have a missing source file in your project list.

[IMG]http://img140.exs.cx/img140/3929/devc3ft.th.gif[/IMG]

You may need to add the file containing the definition the linker needs.

[IMG]http://img140.exs.cx/img140/7249/devc29xk.th.gif[/IMG]

I just had a glance at how to write makefiles. Looks messy

Yeah, makefiles are their own special little hell. But if you get up there on the learning curve they can be useful far beyond just working with code.

Member Avatar
Asif_NSU
Posting Whiz
353 posts since Apr 2004
Reputation Points: 25 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

Trust me Dave, i did attach each and everyfile file required for the project. Like if I used Linked list i added both linkedlist.cpp and linkedlist.h to the project. Still the linker reports undefined reference to linkedlist methods.

Member Avatar
1o0oBhP
Posting Pro in Training
445 posts since Dec 2004
Reputation Points: 4 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Where is the original thread. I might be able to have a look...

Member Avatar
Asif_NSU
Posting Whiz
353 posts since Apr 2004
Reputation Points: 25 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

Where is the original thread. I might be able to have a look...

The original thread deals with smthg totally different :)

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
0
 

Dev-C++ creates a new makefile every time it compiles. Messing with the old one is futile, it gets overwritten.

Member Avatar
Looben
Newbie Poster
12 posts since Dec 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Trust me Dave, i did attach each and everyfile file required for the project. Like if I used Linked list i added both linkedlist.cpp and linkedlist.h to the project. Still the linker reports undefined reference to linkedlist methods.

Execute -> Rebuild All should fix it.

Member Avatar
SpS
Posting Pro
598 posts since Aug 2005
Reputation Points: 34 [?]
Q&As Helped to Solve: 33 [?]
Skill Endorsements: 0 [?]
 
0
 

Execute -> Rebuild All should fix it.

I guess his problem would have been solved by now :mrgreen:

Member Avatar
draike
Newbie Poster
1 post since Feb 2010
Reputation Points: -1 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

exa of class i'm assuming you are using

class c
{
public :
 class a * ac;
 class b * bc;
 c ( const c& );
 ~c(void);
};

/* source file */
c::c(const c&) { /* */ };
c::~c(){/**/};

/******************/
/* making a global declaration should resolve your undefined reference */
/*****************/
a * ac;
b * bc;
Member Avatar
MOHAMEDMAGDY
Newbie Poster
1 post since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-1
 

Try this solution:
Donot put the implementaion of the each function in file
but put it in header file under the class definition and remove the implementaion file

Member Avatar
sagarsindwani
Newbie Poster
1 post since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I am facing linker error in Dev-Cpp using functions line,setcolor etc...
help me out

Member Avatar
Musa_Jutt
Newbie Poster
10 posts since Dec 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i also have a prob but a little diff...

when i run the code every time i got a flash of src ..

after this my Awast anitivirus gave me a massage.. which is "Countinue Execute" i press on it and and coudent find out the OUTPUT secreen...

can any one solve my prob...

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article