How to eliminate Warning LNK4221?

后端 未结 5 2164
伪装坚强ぢ
伪装坚强ぢ 2021-02-18 23:46

I am working on a project using c++/windows forms (visual studio 2010), we have 4 projects:

  • 1 project containing GUI windows forms {managed code} and this is the
5条回答
  •  囚心锁ツ
    2021-02-19 00:32

    Disclaimer: This solution is indeed terrible, and this code should not be added to production build! It is only useful to "hide" the warning.

    A better solution would be to remove the file in question from the compilation, as it is anyway useless.

    Original post:

    I had a the problem with this warning originating from several dependencies, and I found that it was caused by some translation unit being empty, i.e. empty source files.

    These files actually had a content but it was deactivated for visual studio so I just added at the beginning:

    __declspec( dllexport ) void getRidOfLNK4221(){}
    

    And now my project compiles without any warning :)

    Hope it helps, even if this is a late answer!

提交回复
热议问题