Making a CLI CPP project from static library to DLL is causing LNK2020 linking errors

24 views Asked by At

I have a CLI/CPP Project (say ProjA). It is referring for some functions defined in another CLI CPP static library (say ProjB). I added ProjB as reference to ProjA.

ProjB also has some unmanaged cpp file which been exported by __declspec

Now when I try to compile ProjA (with configuration type as .dll) I am getting Linking error. error LNK2020: unresolved token (06000046) namespace::AFunction. ; here AFunction is a static function of a managed cpp class(ref class) defined in ProjA.

But if ProjA's configuration is changed to Static Library (.lib) its building fine.

Could you please help me in resolving the problem or how can I make ProjA a DLL?

1

There are 1 answers

0
WyattK1093 On

When creating a dynamic library, it requires you to link it. But when creating a static library it does not.

A static library is almost like a zip file with a bunch of object files inside it.

You must be missing an argument to the linker to link with the missing function.

Please provide more specific information like your build system and/or compiler arguments, and a simple code example.