473,756 Members | 3,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error LNK2019: unresolved external symbol with Studio.NET 2003!

Hi, All
I am migrating to Studio .NET 2003 from Studio 6.0 and Studio .NET 2002. When I compiled my code, which is compilable both in VC++ 6.0 and Studio .NET 2002, I have an error LNK2019 as the following

-------------------------------------------------------------------------
error LNK2019: unresolved external symbol "class CPV3<double> __cdecl operator*(doubl e,class CPV3<double> const &)" (??D@YA?AV?$CPV 3@N@@NABV0@@Z) referenced in function _mai
-------------------------------------------------------------------------

The error is related to a template function! Does any body have any idea to solve this problem

#include "stdafx.h
#include "PV3.h

int _tmain(int argc, _TCHAR* argv[]

CPV3<double> aVec, bVec

aVec.x = 1.0
aVec.y = 2.0
aVec.z = 3.0

bVec.x = 2.0
bVec.y = 2.0
bVec.z = 2.0

aVec = 2.0*bVec; // error LNK2019: unresolved external symbol

Swap(bVec,aVec) ; // this function works wel
return 0
// -------------------------------
// file "PV.h

template< class T
class CPV

// Attribute
public
/
unio

struc

T x
T y
T z
}
}
// Method
public
CPV3()
~CPV3()
friend CPV3<T> operator * ( const double dMul, const CPV3<T>& a )
friend void Swap( const CPV3<T>& a, const CPV3<T>& b )
}

template< class T
CPV3<T>::CPV3(

template< class T
CPV3<T>::~CPV3(

template< class T
CPV3<T> operator * ( const double dMul, const CPV3<T>& a

CPV3<T> pv( a )

pv.x *= dMul; pv.y *= dMul; pv.z *= dMul

return pv
template< class T
void Swap( CPV3<T>& a, CPV3<T>& b

CPV3<T> tmp(a)

a = b
b = tmp

// ------ end of file PV.h --------

// --------------------------------
// File PV.cp
#include "stdafx.h
#include "PV3.h

template class CPV3< double >

template CPV3<double> operator * ( const double dMul
const CPV3<double>& a )
template void Swap( CPV3<double>& a, CPV3<double>& b )

// ------- Enf of file PV.cpp --------
Nov 17 '05 #1
3 5849
>I am migrating to Studio .NET 2003 from Studio 6.0 and Studio .NET 2002. When I compiled my code, which is compilable both in VC++ 6.0 and Studio .NET 2002, I have an error LNK2019 as the following:

--------------------------------------------------------------------------
error LNK2019: unresolved external symbol "class CPV3<double> __cdecl operator*(doubl e,class CPV3<double> const &)" (??D@YA?AV?$CPV 3@N@@NABV0@@Z) referenced in function _main
--------------------------------------------------------------------------

The error is related to a template function! Does any body have any idea to solve this problem!


I can also reproduce your problem with VS2003 and the VS2005 preview
compiler, and as it builds and runs fine with VC6, it would appear to
be a bug or some obscure C++-ism I'm not aware of. Since it looks like
a bug to me, I'll try to pass it on to MS.

I'm afraid I don't have a suggested work-around, so unless someone
else has an idea, I suggest that you phone MS PSS and see what they
have to say about it.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 17 '05 #2
>I can also reproduce your problem with VS2003 and the VS2005 preview
compiler, and as it builds and runs fine with VC6, it would appear to
be a bug or some obscure C++-ism I'm not aware of.


It turns out to be a subtle C++-ism.

If you change the friend declaration to this:

template< class U >
friend CPV3 operator* ( const double dMul, const CPV3 & a );

it'll compile and work fine.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 17 '05 #3
Hi, David

I have figured out that adding template <class T> in front of friend is enough, no other changes are necessary!

My program works well wit

template <class T> friend CPV3<T> operator * ( const double dMul, const CPV3<T>& a )

Just let you know! Thank you again

Ya

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2161
by: Vishal Saxena | last post by:
Hi, I am new to this news group, hope to get prompt solution from you, gurus of VC. Well i had a project developed in VC++ 6.0, it uses Adobe Plugin Development SDK, I am trying to upgrade my project to VC++.NET, below is the code snipplet from the project
2
1584
by: hazizpour | last post by:
Hello I hope I am in the correct newsgroup, if not please let me know. I am trying to build a sample for using a certain library ( IFC mapping to C++ classes, see www.cstb.fr) with MS Visual Studio 2003. When building a sample program, I get the error mentioned in the title: LNK2019 Here is a snippet of the error message:
0
1689
by: Usman | last post by:
Hi I've a COM compiled in visual studio 6 that is internally using zlib library (an opensource library for compression). I've no problem compiling that code. But when I moved to visual studio.Net it started giving me linker errors. The errors are given below. Is there any compiler option in the .Net studio that I'm missing because if there were a problem with the zlib library that I'm using, it must have given errors in VS 6 too. If...
4
6405
by: Sanjay Kumar | last post by:
Folks ! I am working with VC++ after a long time and having problem linking latest xerces 2.7 in VC++ 2005 Express Edition. I have done following: 1. downloaded and unpacked the the library: http://www.apache.org/dist/xml/xerces-c/binaries/xerces-c_2_7_0-windows_2000-msvc_60.zip
1
3293
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly, but throws a load of linker errors
2
5331
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: 1>make_buildinfo.obj : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _make_buildinfo2 Ask on python-list@python.org . - Josiah
4
9057
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 LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "public: void __thiscall GLTexture::Use(void)" (?Use@GLTexture@@QAEXXZ) GLTexture.obj Error 12 error LNK2001: unresolved external symbol __imp__glEnable@4 Model_3DS.obj ...
0
1556
by: Ling | last post by:
I am using boost.python to wrap C++ function which includes directmusic libraries to simply play the midi, but lots of linkage errors "error LNK2001: unresolved external symbol". I wonder if it is possible to work with DirectX - directmusic libs. Are there any ways to wrap it? *********************compilation errors ************************* msvc.link.dll bin\msvc-7.1\debug\threading-multi\playmusic.pyd bin \msvc-7.1\debu...
2
11485
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 external symbol __imp__inet_ntoa@4 referenced in function _got_packet error LNK2019: unresolved external symbol __imp__ntohs@4 referenced in function _got_packet error LNK2019: unresolved external symbol _Search referenced in function _got_packet...
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.