C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 30th, 2002, 03:21 AM
gamgee gamgee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Ireland
Posts: 26 gamgee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Linker Error

I recieve this error :
[Linker error] undefined reference to `Tag_Path::Tag_Path(vector<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> >, allocator<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > > >)'

when I try to compile my code. Im sure there is some very simple explanation for it but I have tried everything I can think of. Im not sure if Im allowed to post my code but I dont know how else anyone can help me. And the length of the code is fairly short.

Firstly I have a tester class Tag_Path_Tester:
int main()
{
cout << "Creating vector of strings vs \n";
vector<string> vs(5);
vs[0] = "zero";
vs[1] = "one";
vs[2] = "two";
vs[3] = "three";
vs[4] = "four";
cout << "Creating a Tag_Path variable t /n";
Tag_Path t = Tag_Path(vs);
/*cout << "Tag Path contents \n";
for (int i=0; i<(t.get_path()).size(); i++)
{
cout << (t.get_path())[i];
}

/*wait*/int x;
cin >> x;
}
As one can see that uses my own class Tag_Path which follows. The Header file, and then the other

Header :
class Tag_Path
{
public:

Tag_Path(vector<string> paths);
void add_road(string road);
void remove_top_element();
string get_top_element() const;
vector<string> get_path() const;

private:
vector<string> roads;
};
Implementation
Tag_Path::Tag_Path(vector<string> paths)
{
roads = paths;
}


void Tag_Path::add_road(string road)
{
roads.push_back(road);
}

void Tag_Path::remove_top_element()
{
roads.pop_back();
}

string Tag_Path::get_top_element() const
{
return roads[roads.size()-1];
}

vector<string> Tag_Path::get_path() const
{
return roads;
}

N.B. Im using Dev-C 4.9.6.0 as my compiler and I left out things like using namespace std and the #includes to try reduce the code length.

Reply With Quote
  #2  
Old October 30th, 2002, 08:15 AM
ClayDowling ClayDowling is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Flint, MI
Posts: 328 ClayDowling User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 25 sec
Reputation Power: 11
The problem probably has to do with including the implementation object into the project for the executable. I don't know the specifics of your development environment, but typos and missing object files are the most likely problems.
__________________
Clay Dowling
Lazarus Notes
Articles and commentary on web development
http://www.lazarusid.com/notes/

Reply With Quote
  #3  
Old October 30th, 2002, 04:29 PM
gamgee gamgee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Ireland
Posts: 26 gamgee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your input thus far. While there could be typos I dont seem to see them , and you obviously didnt either.
The includes i have for the files are as follows:
Tag_Path_Test.cpp:
#include <iostream>
#include <string>
#include <vector>
#include <Tag_Path.h>

Tag_Path.cpp:
#include <Tag_Path.h>

Tag_Path.h:
#include <vector>
#include <string>

It really is a very basic class.
There is one other thing of note
I get an error when I try to compile Tag_Path.cpp
Winmain@'16
maybe this free compiler I have is not so good. You get nothing for nothing in this world I guess?

Reply With Quote
  #4  
Old October 30th, 2002, 05:14 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,387 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 21 h 39 m 3 sec
Reputation Power: 4080
Shouldn't
Tag_Path t = Tag_Path(vs);
be written as:
Tag_Path t = new Tag_Path(vs);

Reply With Quote
  #5  
Old October 31st, 2002, 08:32 AM
ClayDowling ClayDowling is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Flint, MI
Posts: 328 ClayDowling User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 25 sec
Reputation Power: 11
Quote:
Originally posted by gamgee
There is one other thing of note
I get an error when I try to compile Tag_Path.cpp
Winmain@'16
maybe this free compiler I have is not so good. You get nothing for nothing in this world I guess?


Don't knock the free compilers. The GNU compilers are free and very excellent quality. Cygwin Distribution from Redhat is probably the easiest to install.

The error message is very indicative of your problem. First, if Tag_Path.cpp is a class implementation, it definitely shouldn't have a Winmain function. Second, it's failure to compile would lead directly to a linking error in any module which uses the Tag_Path library implementation.

Reply With Quote
  #6  
Old November 5th, 2002, 11:45 AM
gamgee gamgee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Ireland
Posts: 26 gamgee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
still have problems.....

Can someone please tell me quickly....
...is it correct to have a parameter of type <vector> string in a constructor. Some told me to change 'em for char * but Im not so sure...

Reply With Quote
  #7  
Old November 6th, 2002, 04:43 PM
gamgee gamgee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Ireland
Posts: 26 gamgee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cheers

Id like to just thank anyone who replied to my posting or even botherd to look at it. I have solved the problem, and I guess I should be feeling a little foolish right now. I was trying to compile the three files individually. They were not part of a project. once I created a project and added them to it, complied perfectly

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Linker Error

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap