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

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::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 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 4244
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.BrassVersion::.cto
LINK : error LNK2020: unresolved token (06000051) Brass.BrassVersion::.cto
LINK : error LNK2020: unresolved token (06000052) Brass.BrassVersion::Finaliz
LINK : error LNK2020: unresolved token (06000053) Brass.BrassVersion::ToStrin

These relate to the functions in the Brass::BrassVersion 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::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 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
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...
1
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,...
3
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...
2
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...
0
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...
0
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...
0
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...
1
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...
3
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...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.