LNK2020 error with static library (C++).

G

Guest

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?
 
G

Guest

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top