473,413 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

LNK2019 on you own non-static class member functions Oo

I am having trouble with a LNK2019 on a member function.

Here is the error:
Expand|Select|Wrap|Line Numbers
  1. main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Stat::openFile(char *)" (?openFile@Stat@@QAEXPAD@Z) referenced in function _main
As all functionality is made by me or uses simply c++'s main libraries through its header files, there was no need to add any *.lib files.

This is using Visual Studio .NET 2005.

Here is main:

Expand|Select|Wrap|Line Numbers
  1. #include "Stat.h"
  2.  
  3. int main(int argc, char* argv[])
  4. {
  5.   Stat* stat = new Stat();
  6.  
  7.   stat->openFile(argv[1]);
  8.  
  9.   return 0;
  10. }
Here is Stat.h:

Expand|Select|Wrap|Line Numbers
  1. #ifndef STAT_H
  2. #define STAT_H
  3.  
  4. #include "IndexedLinkList.h"
  5.  
  6. class Stat
  7. {
  8. public:
  9.  
  10.   Stat();
  11.   ~Stat();
  12.  
  13.   void openFile(char*);
  14.  
  15. private:
  16.  
  17.   IndexedLinkList* list;
  18. };
  19.  
  20. #endif
Please let me know what needs to be done. If there is any more information you require, please ask.

Thank you
May 2 '07 #1
6 3190
weaknessforcats
9,208 Expert Mod 8TB
I see the declaration:

void openFile(char*);

as a member function of the Stat class.

The compiler has no problem with this. It just marks the function as an unresolved external reference. The linker picks up on this and looks for the code for the function and can't find it. Neither can I.

Where is the code for this function? You need to add it to the build probably by adding the source file with the code to your IDE project.
May 2 '07 #2
all of the files are included with the project

Here is Stat.cpp:

Expand|Select|Wrap|Line Numbers
  1. #include "IndexedLinkList.h"
  2. #include "Stat.h"
  3.  
  4. #include <iostream>
  5. #include <fstream>
  6.  
  7. using namespace std;
  8.  
  9. Stat::Stat()
  10. {
  11.   list = new IndexedLinkList();
  12. }
  13.  
  14. Stat::~Stat()
  15. {
  16.   delete list;
  17. }
  18.  
  19. void openFile(char* f)
  20. {
  21.   fstream file(f, ios_base::binary | ios_base::in);
  22.  
  23.   // do stuff
  24. }
May 2 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
This function:
Expand|Select|Wrap|Line Numbers
  1. void openFile(char* f)
  2. {
  3.   fstream file(f, ios_base::binary | ios_base::in);
  4.  
  5.   // do stuff
  6. }
  7.  
is not a member function of the Stat class.

Where is the Stat::openFile() function ???
May 2 '07 #4
wow, cant believe I missed that...
I suppose I should read my code a little closer.

thanks for your patience.
May 2 '07 #5
weaknessforcats
9,208 Expert Mod 8TB
One day you will understand why I saw that so quickly. Just don't tell anyone, OK?
May 3 '07 #6
svlsr2000
181 Expert 100+
C++ uses name mangling to manage overloaded functions. All the Functions names are mangled during compile time.

If you are more intrested in knowing about the linker error, you can read more on name mangling.
http://www.kegel.com/mangle.html
May 3 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tim | last post by:
I am just creating a hellow world program and it gave me these errors. can you help me out how to resolve this? Thanks, Tim #include <iostream> using namespace std;
0
by: Jennifer | last post by:
Could you please report the following problem to your VC customer support? THANKS! Jennifer The problem is specific to the VC.Net and VC.Net 2003 <xlocinfo> headers. The problem is that if...
3
by: sheep | last post by:
Hi, I are trying to update my project from VC6 to VC7.1. However, I got the following error. Is there anyone knows what the error means and what I should do to solve this problem? Thank you very...
0
by: Droopy Toon | last post by:
Hi, I think it is a FAQ but I found no answer to my problem. I created a C# program that called some C++ legacy code. I created 2 projects : 1) a DLL (IPRCommWrapper.dll) including an...
8
by: Bruce Schechter | last post by:
I am quite experienced with vs.net 2003 and c# but fairly new to c++. I have a test app in c++ that I need to compile for a c#/c++ interop evaluation I'm doing. But first, I simply need to...
3
by: Chris B | last post by:
Im trying out VS.NET 2003 by trying to make my own single linked list library. Im trying to use templates but keep getting LNK2019 errors. Right now I slimmed down my project to just the main.cpp,...
7
by: solarin | last post by:
Im having several problems with the error LNK2019. I ve a class that derives from another: //controller.h #include MessagesNotifier_Client class Controller : public...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
4
by: jk2l | last post by:
Error 10 error LNK2019: unresolved external symbol __imp__glBindTexture@8 referenced in function "public: void __thiscall GLTexture::Use(void)" (?Use@GLTexture@@QAEXXZ) GLTexture.obj Error 11 error...
2
by: hjazz | last post by:
Hi all, I'm new to VS, and I'm using Visual Studio .NET 2003. I'm trying to write a program which uses pcap libraries. However, I keep getting the following errors: error LNK2019: unresolved...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.