Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMakeLists: avoid adding/compiling sources twice in static lib #260

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

obligaron
Copy link

When compiling as static library the "main" sources (libztSrcGlob) are added to zt_pic and the static library itself.
The static library on the other hand also includes zt_pic. That means the code is included twice and MSVC warns about it (LNK4006).
This PR removes the second include/compilation.

When compiling with MSVC this PR removes 256 warnings.
Found in devilutionX (see also related discussion).

Example warnings:

VirtualTap.cpp.obj : warning LNK4006: "bool ZeroTier::_has_exited" (?_has_exited@ZeroTier@@3_NA) already defined in VirtualTap.cpp.obj; second definition ignored
VirtualTap.cpp.obj : warning LNK4006: "bool ZeroTier::_has_started" (?_has_started@ZeroTier@@3_NA) already defined in VirtualTap.cpp.obj; second definition ignored
VirtualTap.cpp.obj : warning LNK4006: "int ZeroTier::netifCount" (?netifCount@ZeroTier@@3Ha) already defined in VirtualTap.cpp.obj; second definition ignored
VirtualTap.cpp.obj : warning LNK4006: "public: __cdecl ZeroTier::VirtualTap::VirtualTap(char const ,class ZeroTier::MAC const &,unsigned int,unsigned int,unsigned __int64,void (__cdecl)(void *,void *,unsigned __int64,class ZeroTier::MAC const &,class ZeroTier::MAC const &,unsigned int,unsigned int,void const *,unsigned int),void *)" (??0VirtualTap@ZeroTier@@qeaa@PEBDAEBVMAC@1@II_KP6AXPEAX3211IIPEBXI@Z3@Z) already defined in VirtualTap.cpp.obj; second definition ignored
VirtualTap.cpp.obj : warning LNK4006: "public: __cdecl ZeroTier::VirtualTap::~VirtualTap(void)" (??1VirtualTap@ZeroTier@@qeaa@XZ) already defined in VirtualTap.cpp.obj; second definition ignored
VirtualTap.cpp.obj : warning LNK4006: "public: void __cdecl ZeroTier::VirtualTap::setEnabled(bool)" (?setEnabled@VirtualTap@ZeroTier@@QEAAX_N@Z) already defined in VirtualTap.cpp.obj; second definition ignored
VirtualTap.cpp.obj : warning LNK4006: "public: bool __cdecl ZeroTier::VirtualTap::enabled(void)const "

@joseph-henry
Copy link
Contributor

Thanks for catching this. This does appear to be some sort of copy and paste error since it makes no sense for it to be there. I don't have MSVC handy but I did test this on Linux and it doesn't cause any new issues.

@joseph-henry joseph-henry changed the base branch from main to dev November 17, 2023 22:33
@joseph-henry joseph-henry merged commit ff93311 into zerotier:dev Nov 17, 2023
@obligaron obligaron deleted the cmakelist branch November 18, 2023 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants