473,785 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Frustrating LNK2001 issue with VC++ 6.0

Hi Everyone,

I have been trying resolve this issue for many hours and am not making
any progress. I have a DLL that I'm updating with some new 3rd party
libraries. However, there appears to be a conflict causing the
following link errors:
------------
error LNK2001: unresolved external symbol "void __cdecl operator
delete[](void *)" (??_V@YAXPAX@Z)
error LNK2001: unresolved external symbol __ftol2
error LNK2001: unresolved external symbol "void * __cdecl operator
new[](unsigned int)" (??_U@YAPAXI@Z)
-------------
And that's it, there are no other errors.

Generally it is my understanding that when there is an unresolved
external symbol, it simply means that I'm missing a .lib from my
project settings. In this case, I would think that adding msvcrt.lib
to the project would fix it, but it does not. I tried compiling this
both with and without default libraries with the same result.

To troubleshoot this problem I reduced my project to a very simple
example, which compiled fine. I then began adding back in my source
code one bit at a time until the problem cropped up again, but I still
have not been able to figure out exactly where it is coming from.

Any ideas?

Thanks in advance for any help!

Apr 15 '07 #1
6 3215
walkerfx wrote:
Hi Everyone,

I have been trying resolve this issue for many hours and am not making
any progress. I have a DLL that I'm updating with some new 3rd party
libraries. However, there appears to be a conflict causing the
following link errors:
------------
error LNK2001: unresolved external symbol "void __cdecl operator
delete[](void *)" (??_V@YAXPAX@Z)
error LNK2001: unresolved external symbol __ftol2
error LNK2001: unresolved external symbol "void * __cdecl operator
new[](unsigned int)" (??_U@YAPAXI@Z)
-------------
And that's it, there are no other errors.

Generally it is my understanding that when there is an unresolved
external symbol, it simply means that I'm missing a .lib from my
project settings.
It can mean you have the wrong .lib file (e.g. a different, incompatible
version), rather than a missing one.

In this case, I would think that adding msvcrt.lib
to the project would fix it, but it does not. I tried compiling this
both with and without default libraries with the same result.

To troubleshoot this problem I reduced my project to a very simple
example, which compiled fine. I then began adding back in my source
code one bit at a time until the problem cropped up again, but I still
have not been able to figure out exactly where it is coming from.

Any ideas?
Try changing the runtime library setting under
Project->Settings->C/C++->Code Generation (IIRC). The setting must match
that which the lib file was generated against.

Generally, you should not need to use the no default libraries setting.
Instead, you just need to make sure that the library settings match. See
also here:
http://msdn2.microsoft.com/en-us/lib...1z(vs.71).aspx

Tom
Apr 16 '07 #2
On Apr 16, 2:42 am, "Tom Widmer [VC++ MVP]" <tom_use...@hot mail.com>
wrote:
walkerfx wrote:
Hi Everyone,
I have been trying resolve this issue for many hours and am not making
any progress. I have a DLL that I'm updating with some new 3rd party
libraries. However, there appears to be a conflict causing the
following link errors:
------------
error LNK2001: unresolved external symbol "void __cdecl operator
delete[](void *)" (??_V@YAXPAX@Z)
error LNK2001: unresolved external symbol __ftol2
error LNK2001: unresolved external symbol "void * __cdecl operator
new[](unsigned int)" (??_U@YAPAXI@Z)
-------------
And that's it, there are no other errors.
Generally it is my understanding that when there is an unresolved
external symbol, it simply means that I'm missing a .lib from my
project settings.

It can mean you have the wrong .lib file (e.g. a different, incompatible
version), rather than a missing one.

In this case, I would think that adding msvcrt.lib
to the project would fix it, but it does not. I tried compiling this
both with and without default libraries with the same result.
To troubleshoot this problem I reduced my project to a very simple
example, which compiled fine. I then began adding back in my source
code one bit at a time until the problem cropped up again, but I still
have not been able to figure out exactly where it is coming from.
Any ideas?

Try changing the runtime library setting under
Project->Settings->C/C++->Code Generation (IIRC). The setting must match
that which the lib file was generated against.

Generally, you should not need to use the no default libraries setting.
Instead, you just need to make sure that the library settings match. See
also here:http://msdn2.microsoft.com/en-us/lib...1z(vs.71).aspx

Tom
Thank you Tom, that is helpful information. I was finally able to
isolate the problem. It comes down to code that calls a static member
method of a class from a 3rd party library. It looks like this:
class::method(& id);

If I comment out the line, the link errors go away. I'm not sure how
to fix it though.

I have looked at my Code Generation settings as you suggested and they
are set the same as the example projects which build fine
(multithreaded DLL). I tried some different settings but they result
in another set of link errors. I have read through the LNK2001 page
you sent but it does not give any insight into static class methods,
only C style static variables and functions.

Apr 16 '07 #3
Have you also linked the third party lib?
What you describe is exactly the error you get when you use a function from
another lib and don´t link it.

Ronny

"walkerfx" <st***@walkerfx .comschrieb im Newsbeitrag
news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
On Apr 16, 2:42 am, "Tom Widmer [VC++ MVP]" <tom_use...@hot mail.com>
wrote:
>walkerfx wrote:
Hi Everyone,
I have been trying resolve this issue for many hours and am not making
any progress. I have a DLL that I'm updating with some new 3rd party
libraries. However, there appears to be a conflict causing the
following link errors:
------------
error LNK2001: unresolved external symbol "void __cdecl operator
delete[](void *)" (??_V@YAXPAX@Z)
error LNK2001: unresolved external symbol __ftol2
error LNK2001: unresolved external symbol "void * __cdecl operator
new[](unsigned int)" (??_U@YAPAXI@Z)
-------------
And that's it, there are no other errors.
Generally it is my understanding that when there is an unresolved
external symbol, it simply means that I'm missing a .lib from my
project settings.

It can mean you have the wrong .lib file (e.g. a different, incompatible
version), rather than a missing one.

In this case, I would think that adding msvcrt.lib
to the project would fix it, but it does not. I tried compiling this
both with and without default libraries with the same result.
To troubleshoot this problem I reduced my project to a very simple
example, which compiled fine. I then began adding back in my source
code one bit at a time until the problem cropped up again, but I still
have not been able to figure out exactly where it is coming from.
Any ideas?

Try changing the runtime library setting under
Project->Settings->C/C++->Code Generation (IIRC). The setting must match
that which the lib file was generated against.

Generally, you should not need to use the no default libraries setting.
Instead, you just need to make sure that the library settings match. See
also here:http://msdn2.microsoft.com/en-us/lib...1z(vs.71).aspx

Tom

Thank you Tom, that is helpful information. I was finally able to
isolate the problem. It comes down to code that calls a static member
method of a class from a 3rd party library. It looks like this:
class::method(& id);

If I comment out the line, the link errors go away. I'm not sure how
to fix it though.

I have looked at my Code Generation settings as you suggested and they
are set the same as the example projects which build fine
(multithreaded DLL). I tried some different settings but they result
in another set of link errors. I have read through the LNK2001 page
you sent but it does not give any insight into static class methods,
only C style static variables and functions.

Apr 16 '07 #4
walkerfx wrote:
On Apr 16, 2:42 am, "Tom Widmer [VC++ MVP]" <tom_use...@hot mail.com>
wrote:
>walkerfx wrote:
>>error LNK2001: unresolved external symbol __ftol2
I've just noticed, that is a VC7 function, not a VC6 one, I think! You
need to get a version of the 3rd party library for VC6 - you've got the
VC7 version.

If there isn't one, you could try adding this code to a .cpp:

extern "C" long _ftol( double ); //defined by VC6 C libs
extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource );}

That leaves the new[]/delete[] errors. To fix those, you could try
adding a call to new[] and delete[] to your code, if you don't already
have any.

Tom
Apr 16 '07 #5
On Apr 16, 7:36 am, "Tom Widmer [VC++ MVP]" <tom_use...@hot mail.com>
wrote:
walkerfx wrote:
On Apr 16, 2:42 am, "Tom Widmer [VC++ MVP]" <tom_use...@hot mail.com>
wrote:
walkerfx wrote:
error LNK2001: unresolved external symbol __ftol2

I've just noticed, that is a VC7 function, not a VC6 one, I think! You
need to get a version of the 3rd party library for VC6 - you've got the
VC7 version.

If there isn't one, you could try adding this code to a .cpp:

extern "C" long _ftol( double ); //defined by VC6 C libs
extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource );}

That leaves the new[]/delete[] errors. To fix those, you could try
adding a call to new[] and delete[] to your code, if you don't already
have any.

Tom
Yes, I believe you are right. I had read a discussion on another list
about the _ftol function with the same conclusion, doing a manual
'reroute' as you suggest.

The documentation for the libraries says that they can be used in
either VC6 or 7, though perhaps this is an oversight or nuance in VC6.
I have contacted the developers to get their help. At this point, I
can omit the code in question and move on and come back to it later.
Hopefully they have some idea of what is wrong.

Thanks for all your help!

Apr 16 '07 #6
On Apr 16, 5:39 am, "Masterchie f" <ronald.p...@ka psch.netwrote:
Have you also linked the third party lib?
What you describe is exactly the error you get when you use a function from
another lib and don´t link it.

Ronny
Thanks Ronny. I went and checked again just to make sure. There are
only two 3rd party libraries to use and I have them both. Well there
is also a third MFC-flavored lib, but I am not using MFC and building
with that version doesn't make a difference.

I have never built a lib that exports C++ static methods, so I'm not
sure how they differ from plain C functions. It seems somewhat
arbitrary or at least esoteric that the link error is with __cdecl new
and delete caused by using a class that has nothing but static methods
in it. It's at least showing me an area I have some things to learn
about ;-)

Apr 16 '07 #7

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

Similar topics

10
763
by: Bil Muh | last post by:
Hello Developers, I use VC++ .NET v2003. By using Windows Forms .NET, I am developing an application which will work with TCP/IP functions. I can Build my application in Debug Mode normally, but, whenever I want to Build at Release Mode, compiler gives LNK2001, LNK2019 ve LNK1120 errors. I read the MSDN documents, unfortunately, I could not solve my problem. I am requesting your help. All errors are below with my application name...
3
6080
by: We need more power captain | last post by:
Hi, I know less than a noob, I've been asked to do some compiles in VC++ 6 without knowing too much at all. (I'm a COBOL program normally so this is all too much for me) I open VC++6, open the workspace and then: Build>Batch Build
0
1243
by: Robert A Riedel | last post by:
In a module DATA.CPP, when attempting to initialize a __gc array as follows: // // Begin sample ... // // // Yes, I include all of the correct assemblies, including MSCORLIB.DLL and all of // the other .NET related paraphernalia.
1
1611
by: Irakli Lomidze | last post by:
Dear Sirs plz Help me I'm Trying compile in C++ .NET 2003 (VS 2003 Enterprise Arcitech) This Code (From MSDN) And Gives LNK2001 Linker Error When i remove "new" operator form constructor all works fine plz help me what happand and how slove this problem This code has no problem in vc++2002 class CppClass {
2
4077
by: Urs Vogel | last post by:
Hi I have a C++ interop project, which links fine with VS2003, but after converting it to VS2005, it compiles everything withour errors/warnugs, but I get the following linker message. DBRDMUM.obj : error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ" (?.cctor@@$$FYMXXZ) I definitely don't have a method named like this, so it must be some
5
2851
by: eberesche | last post by:
Hello, as a novice in ASN.1 I have me to a project in C ++ under use of ASN.1 - structures risquély. One of my colleagues means, this would deal something with masochism ;-). Result should be a DLL which provides the exchange of documents between a DMS and a remote data base. My developing environment is MSVS v.7.1, and the ASN.1 - source texts are generated with the compiler asn1c-0.9.20. Therefore I have in the project cpp-, as well as c...
6
121920
by: sadegh | last post by:
Hi I have a problem with my program in VC++6 When I compile it, the following errors are listed. I spend a lot of time on the groups.google.com to find its reason, but none of comments could not help me. Does any body know what is the problem?. Thanks. OtherFunctions.obj : error LNK2001: unresolved external symbol "int
5
4802
by: bonnielym84 | last post by:
Im new here..didnt noe whether is this the rite way to post my problem..Really need help here..i've been stucked in this error from last wk..My problem is like this..Im using VC++ 6.0 to compile my C codes so that i could generate a dll file out of it and used in my C# program.. When I compile, got no error and no warning. But when i build it, i have these errors.. *beginning* sendrcv.obj : error LNK2001: unresolved external symbol "int...
0
1899
by: bonnielym84 | last post by:
Im new here and im not sure whether is this the right place for me to post my question..anyway..hope that you can help me..i have been stucked in this problem since last wk..My problem is..I'm using VC++6.0 to compile my C code in order to get a DLL file for my C# program..but then..when i compile and build..i get 9 errors..n here they are... *beginning* sendrcv.obj : error LNK2001: unresolved external symbol "int __cdecl CS2_RECEIVE(struct...
0
9480
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
10325
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...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8972
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6739
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
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.