开发者

LNK2020 & LNK1120 errors in old class in old working project since other project added that includes same class

开发者 https://www.devze.com 2023-04-13 08:08 出处:网络
I am getting unexpected linker errors after refactoring my solution from 1 to 3 projects. In this first instance I get two unresolved tokens, like

I am getting unexpected linker errors after refactoring my solution from 1 to 3 projects. In this first instance I get two unresolved tokens, like

error LNK2020: unresolved token (0600000C) Mynamespace.MyClass::unresolvedStaticFunc

error LNK2020: unresolved token (0600000C) Mynamespace.MyClass::unresolvedOtherStaticFunc

fatal error LNK1120: 2 unresolved externals

I have not touched this class in my refactoring. Both methods are declared static in the header but not the开发者_运维技巧 body (cpp file).

I've rechecked my errors and the new project is compiling fine but forcing the old one to break on linking.

I think I need to add files to my new projects but they seem nicely separated into their own folders now. Another project for the shared class perhaps? I am adding what I thought a simple feature and my project count has already tripled.


You should not be #includeing header files containing managed types across multiple projects. Instead, in the new project, add an assembly reference to the old project; this way, the type information will be gathered from the .NET metadata embedded into the old project's assembly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号