如何使用 cl.exe 编译 Google 测试代码

时间:2021-04-24 17:23:31

标签: c++ windows visual-c++ googletest

我正在尝试将一些在 Google Test (gtest) 下运行的 C++ 文件从 Linux 开发环境移植到 Windows 开发环境。我大约十年没有使用 Visual Studio,而且我更像是一个 Linux 人,所以这可能是一个非常无知的问题。如何使用 Visual Studio 2019 的 cl.exe 编译来编译和链接 Google Test?

我有一个简单的示例 test.cpp 文件:

#include "gtest/gtest.h"

TEST(TestCaseName, TestName)
{
    EXPECT_EQ(1, 1);
    EXPECT_TRUE(true);
}

int main(int argc, char** argv)
{
    testing::InitGoogleTest(&argc, argv);
    RUN_ALL_TESTS();
}

我尝试使用以下内容编译它:

cl.exe /I "C:\gtest\include" main.cpp gtest.lib gtest_main.lib

这为我编译,但它没有链接。我得到 26 个未解析的外部变量,例如 __imp___dup、__imp___dup2 和 __imp___creat。我的编译行中是否缺少某些内容?

完整的输出如下,但它可能很混乱,因为我可能犯了一个明显的错误:

test.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\ostream(746): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
C:\Users\dfarm\Source\Repos\Sample-Test1\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.3\build\native\include\gtest/gtest-message.h(106): note: see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>    &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>    &,const char *)' being compiled
Microsoft (R) Incremental Linker Version 14.28.29914.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe 
test.obj 
gtest.lib 
gtest_main.lib 
gtest.lib(gtest-all.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: struct _Cvtvec __thiscall std::_Locinfo::_Getcvt(void)const " (?_Getcvt@_Locinfo@std@@QBE?AU_Cvtvec@@XZ) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: unsigned short const * __thiscall std::_Locinfo::_W_Getdays(void)const " (?_W_Getdays@_Locinfo@std@@QBEPBGXZ) already defined in libcpmt.lib(wlocale.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: unsigned short const * __thiscall std::_Locinfo::_W_Getmonths(void)const " (?_W_Getmonths@_Locinfo@std@@QBEPBGXZ) already defined in libcpmt.lib(wlocale.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "protected: __thiscall std::basic_streambuf<char,struct std::char_traits<char    >::basic_streambuf<char,struct std::char_traits<char    >(void)" (??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: virtual __thiscall std::basic_streambuf<char,struct std::char_traits<char    >::~basic_streambuf<char,struct std::char_traits<char    >(void)" (??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char    >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "protected: char * __thiscall std::basic_streambuf<char,struct std::char_traits<char    >::_Pninc(void)" (?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: virtual __thiscall std::basic_ios<char,struct std::char_traits<char    >::~basic_ios<char,struct std::char_traits<char    >(void)" (??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char    >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char    >::widen(char)const " (?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "protected: __thiscall std::basic_ios<char,struct std::char_traits<char    >::basic_ios<char,struct std::char_traits<char    >(void)" (??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char    >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char        & __thiscall std::basic_ostream<char,struct std::char_traits<char    >::operator<<(int)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char        & __thiscall std::basic_ostream<char,struct std::char_traits<char    >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: __thiscall std::basic_iostream<char,struct std::char_traits<char    >::basic_iostream<char,struct std::char_traits<char    >(class std::basic_streambuf<char,struct std::char_traits<char        *)" (??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z) already defined in test.obj
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: virtual __thiscall std::basic_iostream<char,struct std::char_traits<char    >::~basic_iostream<char,struct std::char_traits<char    >(void)" (??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in test.obj
   Creating library test.lib and object test.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4217: symbol '__invalid_parameter_noinfo_noreturn' defined in 'libucrt.lib(invalid_parameter.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"public: class testing::Message & __thiscall testing::Message::operator<<<class testing::Message>(class testing::Message const &)" (??$?6VMessage@testing@@@Message@testing@@QAEAAV01@ABV01@@Z)'
LINK : warning LNK4217: symbol '_calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"wchar_t * __cdecl std::_Maklocwcs(wchar_t const *)" (?_Maklocwcs@std@@YAPA_WPB_W@Z)'
LINK : warning LNK4217: symbol '_free' defined in 'libucrt.lib(free.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"public: __thiscall testing::internal::RE::~RE(void)" (??1RE@internal@testing@@QAE@XZ)'
LINK : warning LNK4217: symbol '_malloc' defined in 'libucrt.lib(malloc.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"private: void __thiscall testing::internal::RE::Init(char const *)" (?Init@RE@internal@testing@@AAEXPBD@Z)'
LINK : warning LNK4217: symbol '__errno' defined in 'libucrt.lib(errno.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"bool __cdecl testing::internal::ParseNaturalNumber<int>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char        const &,int *)" (??$ParseNaturalNumber@H@internal@testing@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAH@Z)'
LINK : warning LNK4217: symbol '_exit' defined in 'libucrt.lib(exit.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"int __cdecl testing::internal::Int32FromEnvOrDie(char const *,int)" (?Int32FromEnvOrDie@internal@testing@@YAHPBDH@Z)'
LINK : warning LNK4217: symbol '__exit' defined in 'libucrt.lib(exit.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"protected: virtual void __thiscall testing::internal::DeathTestImpl::Abort(enum testing::internal::DeathTest::AbortReason)" (?Abort@DeathTestImpl@internal@testing@@MAEXW4AbortReason@DeathTest@23@@Z)'
LINK : warning LNK4217: symbol '_abort' defined in 'libucrt.lib(abort.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"void __cdecl testing::internal::posix::Abort(void)" (?Abort@posix@internal@testing@@YAXXZ)'
LINK : warning LNK4217: symbol '__set_abort_behavior' defined in 'libucrt.lib(abort.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"public: int __thiscall testing::UnitTest::Run(void)" (?Run@UnitTest@testing@@QAEHXZ)'
LINK : warning LNK4217: symbol '__set_error_mode' defined in 'libucrt.lib(set_error_mode.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"public: int __thiscall testing::UnitTest::Run(void)" (?Run@UnitTest@testing@@QAEHXZ)'
LINK : warning LNK4217: symbol '_strtol' defined in 'libucrt.lib(strtox.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"bool __cdecl testing::internal::ParseInt32(class testing::Message const &,char const *,int *)" (?ParseInt32@internal@testing@@YA_NABVMessage@2@PBDPAH@Z)'
LINK : warning LNK4217: symbol '__strtoui64' defined in 'libucrt.lib(strtox.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"bool __cdecl testing::internal::ParseNaturalNumber<int>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char        const &,int *)" (??$ParseNaturalNumber@H@internal@testing@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAH@Z)'
LINK : warning LNK4217: symbol '_getenv' defined in 'libucrt.lib(getenv.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"bool __cdecl testing::internal::BoolFromGTestEnv(char const *,bool)" (?BoolFromGTestEnv@internal@testing@@YA_NPBD_N@Z)'
LINK : warning LNK4217: symbol '___acrt_iob_func' defined in 'libucrt.lib(_file.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"public: __thiscall testing::internal::GTestLog::~GTestLog(void)" (??1GTestLog@internal@testing@@QAE@XZ)'
LINK : warning LNK4217: symbol '__wcsicmp' defined in 'libucrt.lib(wcsicmp.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"public: static bool __cdecl testing::internal::String::CaseInsensitiveWideCStringEquals(wchar_t const *,wchar_t const *)" (?CaseInsensitiveWideCStringEquals@String@internal@testing@@SA_NPB_W0@Z)'
LINK : warning LNK4217: symbol '_fclose' defined in 'libucrt.lib(fclose.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char        __cdecl testing::internal::GetCapturedStream(class testing::internal::CapturedStream * *)" (?GetCapturedStream@internal@testing@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAPAVCapturedStream@12@@Z)'
LINK : warning LNK4217: symbol '_fflush' defined in 'libucrt.lib(fflush.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"public: __thiscall testing::internal::GTestLog::~GTestLog(void)" (??1GTestLog@internal@testing@@QAE@XZ)'
LINK : warning LNK4217: symbol '__fileno' defined in 'libucrt.lib(fileno.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"void __cdecl testing::internal::ColoredPrintf(enum testing::internal::GTestColor,char const *,...)" (?ColoredPrintf@internal@testing@@YAXW4GTestColor@12@PBDZZ)'
LINK : warning LNK4217: symbol '_fputc' defined in 'libucrt.lib(fputc.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"void __cdecl testing::internal::DeathTestAbort(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char        const &)" (?DeathTestAbort@internal@testing@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)'
LINK : warning LNK4217: symbol '___stdio_common_vfprintf' defined in 'libucrt.lib(output.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"void __cdecl testing::internal::ColoredPrintf(enum testing::internal::GTestColor,char const *,...)" (?ColoredPrintf@internal@testing@@YAXW4GTestColor@12@PBDZZ)'
LINK : warning LNK4217: symbol '___stdio_common_vsnprintf_s' defined in 'libucrt.lib(output.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '__snprintf_s'
LINK : warning LNK4217: symbol '_strncmp' defined in 'libucrt.lib(strncmp.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"char const * __cdecl testing::internal::ParseFlagValue(char const *,char const *,bool)" (?ParseFlagValue@internal@testing@@YAPBDPBD0_N@Z)'
LINK : warning LNK4217: symbol '_isdigit' defined in 'libucrt.lib(_ctype.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"bool __cdecl testing::internal::ParseNaturalNumber<int>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char        const &,int *)" (??$ParseNaturalNumber@H@internal@testing@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAH@Z)'
LINK : warning LNK4217: symbol '_isxdigit' defined in 'libucrt.lib(_ctype.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"enum testing::internal::CharFormat __cdecl testing::internal::PrintCharsAsStringTo<char>(char const *,unsigned int,class std::basic_ostream<char,struct std::char_traits<char        *)" (??$PrintCharsAsStringTo@D@internal@testing@@YA?AW4CharFormat@01@PBDIPAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)'
LINK : warning LNK4217: symbol '_isspace' defined in 'libucrt.lib(_ctype.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"class testing::AssertionResult __cdecl testing::internal::`anonymous namespace'::HRESULTFailureHelper(char const *,char const *,long)" (?HRESULTFailureHelper@?A0x0fcd2788@internal@testing@@YA?AVAssertionResult@3@PBD0J@Z)'
LINK : warning LNK4217: symbol '_iscntrl' defined in 'libucrt.lib(_ctype.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"bool __cdecl testing::internal::`anonymous namespace'::ContainsUnprintableControlCodes(char const *,unsigned int)" (?ContainsUnprintableControlCodes@?A0x0fcd2788@internal@testing@@YA_NPBDI@Z)'
LINK : warning LNK4217: symbol '_toupper' defined in 'libucrt.lib(tolower_toupper.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char        __cdecl testing::internal::FlagToEnvVar(char const *)" (?FlagToEnvVar@internal@testing@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBD@Z)'
LINK : warning LNK4217: symbol '__isatty' defined in 'libucrt.lib(isatty.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"void __cdecl testing::internal::ColoredPrintf(enum testing::internal::GTestColor,char const *,...)" (?ColoredPrintf@internal@testing@@YAXW4GTestColor@12@PBDZZ)'
LINK : warning LNK4217: symbol '__open_osfhandle' defined in 'libucrt.lib(osfinfo.obj)' is imported by 'gtest.lib(gtest-all.obj)' in function '"public: virtual enum testing::internal::DeathTest::TestRole __thiscall testing::internal::WindowsDeathTest::AssumeRole(void)" (?AssumeRole@WindowsDeathTest@internal@testing@@UAE?AW4TestRole@DeathTest@23@XZ)'
LINK : warning LNK4286: symbol '__close' defined in 'libucrt.lib(close.obj)' is imported by 'OLDNAMES.lib(close.obi)'
LINK : warning LNK4286: symbol '__read' defined in 'libucrt.lib(read.obj)' is imported by 'OLDNAMES.lib(read.obi)'
LINK : warning LNK4286: symbol '__write' defined in 'libucrt.lib(write.obj)' is imported by 'OLDNAMES.lib(write.obi)'
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp___stat64i32 referenced in function "public: bool __thiscall testing::internal::FilePath::DirectoryExists(void)const " (?DirectoryExists@FilePath@internal@testing@@QBE_NXZ)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__fopen referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char        __cdecl testing::internal::GetCapturedStream(class testing::internal::CapturedStream * *)" (?GetCapturedStream@internal@testing@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAPAVCapturedStream@12@@Z)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__fread referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char        __cdecl testing::internal::ReadEntireFile(struct _iobuf *)" (?ReadEntireFile@internal@testing@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAU_iobuf@@@Z)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__fseek referenced in function "unsigned int __cdecl testing::internal::GetFileSize(struct _iobuf *)" (?GetFileSize@internal@testing@@YAIPAU_iobuf@@@Z)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__ftell referenced in function "unsigned int __cdecl testing::internal::GetFileSize(struct _iobuf *)" (?GetFileSize@internal@testing@@YAIPAU_iobuf@@@Z)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__fwrite referenced in function "public: int __thiscall testing::UnitTest::Run(void)" (?Run@UnitTest@testing@@QAEHXZ)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__remove referenced in function "public: __thiscall testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile(void)" (??1ScopedPrematureExitFile@internal@testing@@QAE@XZ)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__fdopen referenced in function "struct _iobuf * __cdecl testing::internal::posix::FDOpen(int,char const *)" (?FDOpen@posix@internal@testing@@YAPAU_iobuf@@HPBD@Z)
OLDNAMES.lib(fdopen.obi) : error LNK2001: unresolved external symbol __imp__fdopen
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp___strdup referenced in function "private: void __thiscall testing::internal::RE::Init(char const *)" (?Init@RE@internal@testing@@AAEXPBD@Z)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__strerror referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char        __cdecl testing::internal::GetLastErrnoDescription(void)" (?GetLastErrnoDescription@internal@testing@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp___stricmp referenced in function "public: static bool __cdecl testing::internal::String::CaseInsensitiveCStringEquals(char const *,char const *)" (?CaseInsensitiveCStringEquals@String@internal@testing@@SA_NPBD0@Z)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp___getcwd referenced in function "public: static class testing::internal::FilePath __cdecl testing::internal::FilePath::GetCurrentDir(void)" (?GetCurrentDir@FilePath@internal@testing@@SA?AV123@XZ)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp___mkdir referenced in function "public: bool __thiscall testing::internal::FilePath::CreateFolder(void)const " (?CreateFolder@FilePath@internal@testing@@QBE_NXZ)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__close referenced in function "void __cdecl testing::internal::CaptureStream(int,char const *,class testing::internal::CapturedStream * *)" (?CaptureStream@internal@testing@@YAXHPBDPAPAVCapturedStream@12@@Z)
OLDNAMES.lib(close.obi) : error LNK2001: unresolved external symbol __imp__close
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__creat referenced in function "void __cdecl testing::internal::CaptureStream(int,char const *,class testing::internal::CapturedStream * *)" (?CaptureStream@internal@testing@@YAXHPBDPAPAVCapturedStream@12@@Z)
OLDNAMES.lib(creat.obi) : error LNK2001: unresolved external symbol __imp__creat
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__dup referenced in function "void __cdecl testing::internal::CaptureStream(int,char const *,class testing::internal::CapturedStream * *)" (?CaptureStream@internal@testing@@YAXHPBDPAPAVCapturedStream@12@@Z)
OLDNAMES.lib(dup.obi) : error LNK2001: unresolved external symbol __imp__dup
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__dup2 referenced in function "void __cdecl testing::internal::CaptureStream(int,char const *,class testing::internal::CapturedStream * *)" (?CaptureStream@internal@testing@@YAXHPBDPAPAVCapturedStream@12@@Z)
OLDNAMES.lib(dup2.obi) : error LNK2001: unresolved external symbol __imp__dup2
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__read referenced in function "void __cdecl testing::internal::FailFromInternalError(int)" (?FailFromInternalError@internal@testing@@YAXH@Z)
OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp__read
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp__write referenced in function "protected: virtual void __thiscall testing::internal::DeathTestImpl::Abort(enum testing::internal::DeathTest::AbortReason)" (?Abort@DeathTestImpl@internal@testing@@MAEXW4AbortReason@DeathTest@23@@Z)
OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp__write
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp___localtime64_s referenced in function "bool __cdecl testing::internal::PortableLocaltime(__int64,struct tm *)" (?PortableLocaltime@internal@testing@@YA_N_JPAUtm@@@Z)
gtest.lib(gtest-all.obj) : error LNK2019: unresolved external symbol __imp___ftime64 referenced in function "__int64 __cdecl testing::internal::GetTimeInMillis(void)" (?GetTimeInMillis@internal@testing@@YA_JXZ)
OLDNAMES.lib(fdopen.obi) : error LNK2001: unresolved external symbol __imp___fdopen
OLDNAMES.lib(creat.obi) : error LNK2001: unresolved external symbol __imp___creat
OLDNAMES.lib(dup.obi) : error LNK2001: unresolved external symbol __imp___dup
OLDNAMES.lib(dup2.obi) : error LNK2001: unresolved external symbol __imp___dup2
MSVCRT.lib(chandler4gs.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
test.exe : fatal error LNK1120: 26 unresolved externals

1 个答案:

答案 0 :(得分:1)

您可能知道,dup()、dup2()、creat() 和朋友都是“标准”C 库函数(“标准”为“常用”)……Vis​​ual Studio 以“不同方式”对待它们。

建议:尝试静态链接,例如heatmap()

<块引用>

https://stackoverflow.com/a/56698430/421195

如下更改您的运行时库设置

import matplot.pyplot as plt import seaborn as sns co_matrics=dataframe.corr() plot.figure(figsize=(15,20)) sns.heatmap(co_matrix, square=True, cbar_kws={"shrink": .5})

另见:Unable to compile VIX Programs

相关问题