Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C++ Libraries / September 2007

Tip: Looking for answers? Try searching our database.

c++: unresolved external symbol...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kai - 07 Sep 2007 16:55 GMT
Hi guys,

I wrote a class witch should be used with windows and linux.

After compiling the project with vs2005 I get an error:

Error   1       error LNK2019: unresolved external symbol "int const
__cdecl
mstrcpy(char *,int,char *)" (?mstrcpy@@YA?BHPADH0@Z) referenced in
function "public: __thiscall CStr::CStr(class CStr &)" (??
0CStr@@QAE@AAV0@@Z)     cstr.obj

Concerning to that error message I forgot to define a header or is
there anything else incorrect in my code?

This is the method the compiler obviously doesn't like:

const errno_t mstrcpy(char* dest, size_t len, char* src)
{
       #ifdef __WIN32__
               return strcpy_s(dest,len,src);
       #elif __unix__
               return (errno_t)((strncpy(dest,src,(size_t)len)!=NULL)?
0:1);
       #else
               return (errno_t)1;
       #endif

}

my header looks like that:

#ifdef __WIN32__
       #include "stdafx.h"
#ifndef __STDIO_H
  #define __STDIO_H
#endif

#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <errno.h>

using namespace std;

Thanks a lot in advance.

Bye
Kai
SvenC - 07 Sep 2007 17:09 GMT
Hi Kai,

> After compiling the project with vs2005 I get an error:
>
[quoted text clipped - 6 lines]
> Concerning to that error message I forgot to define a header or is
> there anything else incorrect in my code?

The header with the prototype seems to be in place, otherwise the compiler
would have told you

> This is the method the compiler obviously doesn't like:

According to your error description the linker is giving the error, not the
compiler, right?

> const errno_t mstrcpy(char* dest, size_t len, char* src)
> {
[quoted text clipped - 8 lines]
>
> }

The above is defined in a cpp or c file, right? I guess you forgot to add
that cpp or c file to your project, hence the linker does not find the
implementation.

--
SvenC
Kai - 08 Sep 2007 10:31 GMT
> Hi Kai,
>
[quoted text clipped - 36 lines]
> --
> SvenC

Would be a simple result but unfortunately it wasn't that easy. Header
files are added to project.
By the way it's a cpp project.
SvenC - 08 Sep 2007 10:44 GMT
Hi Kai,

>> Hi Kai,
>>
[quoted text clipped - 28 lines]
> Would be a simple result but unfortunately it wasn't that easy. Header
> files are added to project.

The header is not the problem, that holds only the declaration. The problem
is the missing definition of mstrcpy.
Where is the definition? Is it a cpp which is part of the project or is it a
separate lib?
If it is a separate lib then you have to add it to
Project->Properties->Linker.

> By the way it's a cpp project.

What is a cpp project?

--
SvenC
Kai - 08 Sep 2007 12:02 GMT
> Hi Kai,
>
[quoted text clipped - 44 lines]
> --
> SvenC
By writing cpp project I do mean a visual studio c++ project
solutiion.

the definition was wrong:
definition had char*, int, char* as parameters and the method required
char*, size_t, char*

a real beginner fault. embarrassing for me...

thank you for your help.

Cya
Kai

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.