godotengine / webrtc-native

The official GDNative WebRTC implementation for non-html exports.
MIT License
210 stars 34 forks source link

Can't build with Godot 4.2-rc1 and MSVC #126

Closed ksubox closed 5 months ago

ksubox commented 10 months ago

Godot version

4.2-rc1

Plugin version

HEAD

System information

Windows 11

Issue description

I try to build webrtc GDExtension for Godot 4.2-rc1. So Cloned repo and checked out godot-cpp 7cd79e4cc64ce484ba04d1919da7d4cd39aab5ff (matched rc1). Built with VS2022 and finally got error:

msvcprt.lib(MSVCP140.dll) : error LNK2005: "protected: void __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::pbump(int)" (?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z) already defined in libcpmt.lib(cout.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "protected: __int64 __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::_Pnavail(void)const " (?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ) already defined in libcpmt.lib(cout.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "protected: void __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::_Init(void)" (?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ) already defined in libcpmt.lib(cout.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "protected: void __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::_Init(char * *,char * *,int *,char * *,char * *,int *)" (?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z) already defined in libcpmt.lib(cout.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "protected: virtual __int64 __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::xsgetn(char *,__int64)" (?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z) already defined in libcpmt.lib(cout.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "protected: virtual __int64 __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::xsputn(char const *,__int64)" (?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z) already defined in libcpmt.lib(cout.obj)
   Creating library bin\extension-4.1\webrtc\lib\libwebrtc_native.windows.template_debug.x86_64.lib and object bin\extension-4.1\webrtc\lib\libwebrtc_native.windows.template_debug.x86_64.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : error LNK1218: warning treated as error; no output file generated
scons: *** [bin\extension-4.1\webrtc\lib\libwebrtc_native.windows.template_debug.x86_64.dll] Error 4098
scons: building terminated because of errors.

Steps to reproduce

Clone repo.

cd webrtc-native\godot-cpp
git checkout 7cd79e4cc64ce484ba04d1919da7d4cd39aab5ff
cd ..
scons platform=windows

And finally get error.

Minimal reproduction project

No response

Faless commented 10 months ago

I try to build webrtc GDExtension for Godot 4.2-rc1.

Note that the current version (godot-cpp for Godot 4.1) is supposed to work in Godot 4.2 . There is no real reason to update godot-cpp to newer versions unless the Godot WebRTC API changes (which is not the case in 4.2).

Faless commented 5 months ago

For now, you can build with MSVC:

scons use_static_cpp=no

For reference this seems caused by the change in https://github.com/godotengine/godot-cpp/pull/1203 which resulted in the default changing from /MD to /MT.

I'll make a new PR to hard-code this fix when MSVC is detected.