【问题标题】:Visual studio 2015 c++ and assembly not buildingVisual Studio 2015 C++ 和程序集未构建
【发布时间】:2015-11-06 23:46:01
【问题描述】:

我最近想开始学习汇编,但在设置要构建的项目时遇到了一些问题。

我想要的是一个 C++ 和汇编项目,但它目前不工作。下面显示的我的汇编代码构建得很好:

ExitProcess PROTO

.data

.code

main proc

    mov rax, 8

    mov rcx, 0
    call ExitProcess

main endp

end

但是当我将 cpp 文件添加到我的项目中时,我得到了大量的链接器错误:

void ToDo()
{
    int i = 0;
}

错误:

1>------ Build started: Project: AssemblyTest, Configuration: Debug x64 ------
1>  test.cpp
1>MSVCRTD.lib(_init_.obj) : error LNK2019: unresolved external symbol _CrtDbgReport referenced in function _CRT_RTC_INIT
1>MSVCRTD.lib(_init_.obj) : error LNK2019: unresolved external symbol _CrtDbgReportW referenced in function _CRT_RTC_INITW
1>MSVCRTD.lib(_error_.obj) : error LNK2019: unresolved external symbol __stdio_common_vsprintf_s referenced in function _vsprintf_s_l
1>MSVCRTD.lib(_error_.obj) : error LNK2001: unresolved external symbol __C_specific_handler
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol _wmakepath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath@@YAHPEB_WPEA_W_K@Z)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol _wsplitpath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath@@YAHPEB_WPEA_W_K@Z)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol wcscpy_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath@@YAHPEB_WPEA_W_K@Z)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __vcrt_GetModuleFileNameW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPEAUHINSTANCE__@@XZ)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __vcrt_GetModuleHandleW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPEAUHINSTANCE__@@XZ)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __vcrt_LoadLibraryExW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPEAUHINSTANCE__@@XZ)
1>C:\Users\***\Desktop\AssemblyTest\x64\Debug\AssemblyTest.exe : fatal error LNK1120: 10 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

有人知道我的设置有什么问题以及如何解决吗?

【问题讨论】:

    标签: c++ assembly visual-studio-2015


    【解决方案1】:

    您仅将项目与 C 运行时 (CRT) 库 msvcrtd.lib 的一部分链接。您还需要链接库vcruntimed.libucrtd.lib。前者是 Visual Studio 2015 本身的一部分,而后者是随 Visual Studio 安装的 Windows 10 SDK 的一部分。通常 C++ 项目会自动链接到这些库,但显然您的项目没有设置。

    您可能会遵循适用于旧版本 Visual Studio 的说明,该版本只需要链接一个 CRT 库文件。这因a refactoring of the CRT with Visual Studio 2015 而改变。

    【讨论】:

    • 或者根本没有,例如/NODEFAULTLIB
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多