473,748 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LNK2020 error with static library (C++).

I'm porting an old project to use .NET. When I try to link in a static library (.lib) that has a single managed class in it. I get the following errors:

LINK : error LNK2020: unresolved token (0600000E) PatInfo::.ctor
LINK : error LNK2020: unresolved token (0600000F) PatInfo::Finali ze
LINK : fatal error LNK1120: 2 unresolved externals

I've striped everything out of this library except for the single class which has an empty constructor and an empty destructor. I have one header file with the class definition and one source file, which has the empty functions in it. Any idea how to get rid of these errors?

Another strange thing I've found. I was trying to see if it was simply not linking the library so I created a global function and called it from my application project. When I did this, not only did the global function load correctly, but the class functions did as well.

The library project is listed as a dependancy for the application project and some of the application source files include the the library header file.

Anyone know how to get past these errors and link static libraries that contain managed classes?
Jul 21 '05 #1
1 4330
mccoyn,

I have run into [what appears to be] the exact same error. Did you happen to find a solution? I'd like to discuss this further (in private, if you'd prefer)

Here's my description, from a different newsgroup post
-----------------
Hi all

I have a .NET solution with several projects in it. One project is a "utilities" project that is compiled into a static library. It contains managed and unmanaged C++ in several files. So I am compiling using managed extensions. This project compiles successfully

Another project in the solution, BrassControls, is dependent on the Utilities project. It uses several of the classes in Utilities. However, it fails at linking. I get the following error when building the BrassControls project [ -- the class BrassVersion is in the Utilities project]

LINK : error LNK2020: unresolved token (06000050) Brass.BrassVers ion::.cto
LINK : error LNK2020: unresolved token (06000051) Brass.BrassVers ion::.cto
LINK : error LNK2020: unresolved token (06000052) Brass.BrassVers ion::Finaliz
LINK : error LNK2020: unresolved token (06000053) Brass.BrassVers ion::ToStrin

These relate to the functions in the Brass::BrassVer sion class. This is the only class in the Utilities project that is a __gc class

I have verified that the project dependencies are set so that BrassControls is dependent on Utilities. But for some reason it can't "see" the tokens associated with BrassVersion

Both projects are compiled using managed extensions. Both are using the same run-time library

Can anyone help me figure this out
Thanks
Matt
-----------------

----- mccoyn wrote: ----

I'm porting an old project to use .NET. When I try to link in a static library (.lib) that has a single managed class in it. I get the following errors:

LINK : error LNK2020: unresolved token (0600000E) PatInfo::.ctor
LINK : error LNK2020: unresolved token (0600000F) PatInfo::Finali ze
LINK : fatal error LNK1120: 2 unresolved externals

I've striped everything out of this library except for the single class which has an empty constructor and an empty destructor. I have one header file with the class definition and one source file, which has the empty functions in it. Any idea how to get rid of these errors?

Another strange thing I've found. I was trying to see if it was simply not linking the library so I created a global function and called it from my application project. When I did this, not only did the global function load correctly, but the class functions did as well.

The library project is listed as a dependancy for the application project and some of the application source files include the the library header file.

Anyone know how to get past these errors and link static libraries that contain managed classes?
Jul 21 '05 #2

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

Similar topics

2
7576
by: Jacob Cohen | last post by:
Under VC7.1, I am trying to wrap a native-C++ DLL that contains C++ objects in a Managed-C++ class library for use in a C# project. I created and compiled the native DLL under VC7.1 as a Win32 DLL C++ (unmanaged) project. I found the decorated names of the symbols I wanted to export and created a .def file, so that it generated an import library. I took this import library and had my Managed-C++ class library link against it. The...
1
9110
by: Tony Baker | last post by:
Hi, If I 1) create a brand new Visual C++ Project -> Class Library (.Net) 2) in the stdafx.h file add #include <atlbase.h> I get the following errors: ------ Build started: Project: testATL, Configuration: Debug Win32 ------ Compiling... Stdafx.cpp
3
2916
by: Simon Jefferies | last post by:
Hello, I am trying to use a Managed C++ .NET (DLL) Class library within my Managed C++ .NET forms application. I have both projects in the same solution and have the class library under my references branch in the forms application. When I build i get the following linker error:-
2
1703
by: Vickie | last post by:
I have a very simple program with some computations. After using NODEFAULTLIB to get rid of LNK2005 errors such as: LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCR71D.dll) Now I have two new LNK2020 errors: LINK : error LNK2020: unresolved token (0A000021) std._Lockit.__dtor LINK : error LNK2020: unresolved token (0A000022) _DebugHeapTag LINK : fatal error LNK1120: 2 unresolved externals
0
1127
by: Stefan | last post by:
Hi, Could anyone share some light on this and how I can work around it. If I have 2 managed c++ dlls (A and B) and B tries to use a native class in A this fails to link. It is easily reproducable by taking the example from: 'http://msdn2.microsoft.com/library/c3d162w5.aspx' And then move the definition(?) of N::N to the cpp file. It will then look like this: // mcppv2_ref_class3.cpp
0
1379
by: Gustavo L. Fabro | last post by:
Greetings! I found myself with a LNK2020 linking problem using VS.NET 2003 under a situation that I was able to replicate in a small project. I found one workaround for the problem too, but it's ugly and sure things shouldn't be like that. I'd like to know if that's a conceptual mistake by me, a compiler error, both, or none of them! ;-) To replicate the problem:
0
2946
by: Roland | last post by:
Hi, ultimately I want to call some unmanaged C++ class that contains some DirectShow code of mine from my C# classes, but for the time being I'd be happy if I could get this to build! I have read the other topics on the same problem here on the groups but haven't found the solution to my problem yet. I have written a managed C++ wrapper class called MDirectShowHandler. This currently wraps only the constructor and destructor calls (see
1
559
by: mccoyn | last post by:
I'm porting an old project to use .NET. When I try to link in a static library (.lib) that has a single managed class in it. I get the following errors: LINK : error LNK2020: unresolved token (0600000E) PatInfo::.ctor LINK : error LNK2020: unresolved token (0600000F) PatInfo::Finalize LINK : fatal error LNK1120: 2 unresolved externals I've striped everything out of this library except for the single class which has an empty constructor...
3
514
by: S Wheeler | last post by:
Hi - I have a vc++ WinForms app. Can I override the WndProc so I can send custom messages to my app. Is there any way to do this? I need to notify the main form of events from a library. How is this done in VC++? Thanks
0
8996
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
8832
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
9562
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
9333
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
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6799
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
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();...
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
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.