473,387 Members | 1,890 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,387 software developers and data experts.

Another noob header question

cypherzero
Using this header file (mstring.h) for a class defined in a seperate file (mstring.cpp) I recieve 8 'unresolved external symbol' errors when trying to use the class in my main source file (main.cpp). Could someone please tell me if I am making yet another newbie mistake? I'm sure this has always worked in the past!

Expand|Select|Wrap|Line Numbers
  1. ///////////////
  2. // mstring.h //
  3. ///////////////
  4. #include <string>
  5.  
  6. class MSTRING : public std::string
  7.     {
  8.     public:
  9.         MSTRING();
  10.         MSTRING(std::string copyfrom);
  11.         MSTRING(char* charpos);
  12.         MSTRING (unsigned long i, int base = 10);
  13.         bool contains(MSTRING txt);
  14.         MSTRING ucase();
  15.         MSTRING lcase();
  16.         MSTRING subst(MSTRING f, MSTRING r);
  17.     };
  18.  
  19. /////////////
  20. // ERRORS: //
  21. /////////////
  22. main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall MSTRING::contains(class MSTRING)" (?contains@MSTRING@@QAE_NV1@@Z) referenced in function "bool __cdecl testfilter(class MSTRING)" (?testfilter@@YA_NVMSTRING@@@Z)
  23. main.obj : error LNK2019: unresolved external symbol "public: __thiscall MSTRING::MSTRING(char *)" (??0MSTRING@@QAE@PAD@Z) referenced in function "void __cdecl out_memstring(char *)" (?out_memstring@@YAXPAD@Z)
  24. main.obj : error LNK2019: unresolved external symbol "public: __thiscall MSTRING::MSTRING(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0MSTRING@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "class MSTRING __cdecl get_windowinfo(struct HWND__ *,int)" (?get_windowinfo@@YA?AVMSTRING@@PAUHWND__@@H@Z)
  25. main.obj : error LNK2019: unresolved external symbol "public: class MSTRING __thiscall MSTRING::lcase(void)" (?lcase@MSTRING@@QAE?AV1@XZ) referenced in function "void __cdecl autofinds(void)" (?autofinds@@YAXXZ)
  26. main.obj : error LNK2019: unresolved external symbol "public: __thiscall MSTRING::MSTRING(void)" (??0MSTRING@@QAE@XZ) referenced in function "void __cdecl autofinds(void)" (?autofinds@@YAXXZ)
  27. main.obj : error LNK2019: unresolved external symbol "public: __thiscall MSTRING::MSTRING(unsigned long,int)" (??0MSTRING@@QAE@KH@Z) referenced in function "void __cdecl out_windowinfo(struct HWND__ *)" (?out_windowinfo@@YAXPAUHWND__@@@Z)
  28. main.obj : error LNK2019: unresolved external symbol "public: class MSTRING __thiscall MSTRING::subst(class MSTRING,class MSTRING)" (?subst@MSTRING@@QAE?AV1@V1@0@Z) referenced in function _main
  29.  
  30.  
Jul 22 '07 #1
3 1357
I think you need a destructor function for your mstring class.

J
Jul 22 '07 #2
Tried it, I get the same errors =o(
Jul 22 '07 #3
The problem is this is only a header, it does not contain the definitions for the class, just declares the interface. So you have to do one of two things to make the code accessible.

1. If this code is in a separate library already, you have to configure your program to link against that DLL (Linux/Unix usually do not have this problem as they can find the proper library usually).

2. If its not already in a library the owner of the mstring.h file should have provided you with a mstring.cpp file with this. You would then add this file into your project as well, so it compiled your code and their code into a single executable.

As it stands now it cannot find any of the code for the class.
Jul 23 '07 #4

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

Similar topics

10
by: Matt Hollingsworth | last post by:
Hello, Very new to python, so a noob question. When I've written stuff in JavaScript or MEL in the past, I've always adopted the variable naming convention of using a $ as the first character...
8
by: Rich Grise | last post by:
I think I've finally found a tutorial that can get me started: http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html and I've been lurking for awhile as well. What happened is,...
2
by: anti-guru | last post by:
This is killing me. How can I make a static array of two strings in my class? Nothing I've tried works. Here is what I currently have, which also doesn't work, but gives the least amount of...
2
by: What nickname do you want? | last post by:
I want to provide secured acces to a MySQL database. This is what I've done. Firstly the relevant pages are in a folder to which Apache requires password authentication. Then I have an HTML page...
8
by: mmu2643 | last post by:
Hi, I was trying to compile the following bit of code: #include <iostream.h> main(){ cout<<"Hello World!";
2
by: daz_oldham | last post by:
Hi All I am re-visiting XSLT after not touching it for about three years, so to be honest I am starting myself from scratch. If I have XML under the namespace "http://tempuri.com/abc/2002/09",...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
4
by: larry | last post by:
Ok I'm a Python noob, been doing OK so far, working on a data conversion program and want to create some character image files from an 8-bit ROM file. Creating the image I've got down, I open...
2
by: noemailplease0001 | last post by:
#ifndef POSITION_H_ #define POSITION_H_ class Position { public: Position(std::string name, std::string name): m_name( name), m_description(description){} std::string toString(); private:
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.