错误LNK2019:VS2019中的函数_printf中引用的未解析的外部符号__imp____acrt_iob_func

Xhero39

我正在使用Visual Studio 2019社区版,并且试图从C程序运行Assembly函数。

我收到以下错误:

  Rebuild started...
    1>------ Rebuild All started: Project: ArrayReverser, Configuration: Debug Win32 ------
    1>Assembling GetValueFromASM.asm...
    1>ArrayReverser.cpp
    1>ArrayReverser.obj : error LNK2019: unresolved external symbol __imp__srand referenced in function _main
    1>ArrayReverser.obj : error LNK2019: unresolved external symbol __imp__rand referenced in function _main
    1>ArrayReverser.obj : error LNK2019: unresolved external symbol __imp____acrt_iob_func referenced in function _printf
    1>ArrayReverser.obj : error LNK2019: unresolved external symbol __imp____stdio_common_vfprintf referenced in function __vfprintf_l
    1>C:\Users\firas\source\repos\ArrayReverser\Debug\ArrayReverser.exe : fatal error LNK1120: 4 unresolved externals
    1>Done building project "ArrayReverser.vcxproj" -- FAILED.
    ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

我已经尝试了几乎可以在Internet上找到的所有解决方案,但是没有任何效果,我希望有人可以对正在发生的事情有所了解。

这是C代码:

#include <iostream>
#include <stdlib.h>



extern "C" void GetValueFromASM(int* y, const int *x, int n);


int main(int argc, char* argv[])
{
    const int n = 10;
    int x[n], y[n];
    srand(41);
        for (int i = 0; i < n; i++)
            x[i] = rand() % 1000;
        GetValueFromASM(y, x, n);


printf("\n---------------Array Reverser-------------\n");
        for (int i = 0; i < n; i++)
        {
            printf("i:     %5d       y: %5d         x: %5d\n", i, y[i], x[i]);
        }

        return 0;
}  
    

这是汇编代码:

.386 
.model flat,c
.code 
 GetValueFromASM  PROC
               push ebp  ;we pushed the register ebp onto the stack
               mov  ebp,esp  
               push esi
               push edi
               
               xor  eax,eax
               ;now we load the parameters (int* y, const int* x, int n) onto edi,esi,ecx
               mov  edi,[ebp+8]  ;bp - stack base Pointer Register 
               mov  esi,[ebp+12]
               mov  ecx,[ebp+16] 
               
               
               ; in order to reverse the array elemtns we use the following command
               lea esi,[esi+ecx*4-4] 
               pushfd
               std
               
    @@:        lodsd 
               mov [edi], eax
               add  edi, 4
               dec  ecx
               jnz @B
               
               popfd
               mov eax,1
               
               
               ;Epilouge
               pop edi
               pop esi
               pop ebp
     
    GetValueFromASM endp
end     

链接到我的项目文件:https : //drive.google.com/file/d/1entjG8nHarDTW0AEmvKhv0Cvrw9v0BF2/view?usp=sharing

迈克尔·佩奇

我下载了您的项目,并观察到类似的链接器错误(实际上,我有更多的错误)。我查看了该项目的所有链接器选项,并注意那些粗体的条目粗体选项尚未被继承。一个引人注目的是Entrypoint

在此处输入图片说明

您用MASM函数覆盖了默认的C启动入口点Reverser我修改了EntryPoint它,使其为空白(将其删除)。当我重建项目时,不再有链接器错误。

您的Reverser函数没有ret结尾,因此在运行时它将引发异常。retReverser函数底部添加了a并运行了代码并得到以下输出:

在此处输入图片说明


注意:@rustyx的建议非常好:“尝试所有解决方案通常都不是MSVC配置的好主意。实际上,应格外小心,不要更改您不知道其效果的任何内容。现在可能值得创建一个新的新项目。” 如果您创建一个全新的CONSOLE项目并且不修改入口点,那么应该没有问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

C ++:错误LNK2019:函数中引用的未解析的外部符号__snprintf

来自分类Dev

C ++:错误LNK2019:函数_main中引用的未解析的外部符号

来自分类Dev

C ++:错误LNK2019:函数_main中引用的未解析的外部符号

来自分类Dev

错误21错误LNK2019:无法解析的外部符号:....在函数:...中引用。

来自分类Dev

LNK2019 未解析的外部符号 GetMonitorBrightness 在函数 main 中引用

来自分类Dev

错误LNK2019:函数main中引用了无法解析的外部符号

来自分类Dev

错误LNK2019:函数___tmainCRTStartup中引用了无法解析的外部符号_wWinMain @ 16

来自分类Dev

错误LNK2019:函数main中引用了无法解析的外部符号

来自分类Dev

使用defalt args时在函数_main中引用的错误LNK2019无法解析的外部符号

来自分类Dev

错误:LNK2019:Qt中无法解析的外部符号

来自分类Dev

LNK2019未解析的外部符号_CrtDbgReport在函数_CRT_RTC_INIT SDL2中引用

来自分类Dev

错误LNK2019:未解析的外部符号“公共:__thiscall RNG :: RNG(unsigned __int64)”(?? 0RNG @@ QAE @ _K @ Z)在函数_main中引用

来自分类Dev

尽管在cpp中有定义,但LNK2019构造函数中未解析的外部符号

来自分类Dev

Boost文件系统库中未解析的外部符号(错误LNK2019)

来自分类Dev

错误LNK2019:无法解析的外部符号:: FindWindow()函数

来自分类Dev

LNK2019:函数___tmainCRTStartup中使用DLL引用的未解析的外部符号_main

来自分类Dev

Visual Studios C ++代码中的错误。Lab4.obj:错误LNK2019:未解析的外部符号“布尔__cdecl

来自分类Dev

LNK2019:C ++ / CLI中无法解析的外部符号

来自分类Dev

LNK2019 和 LNK1120 错误,未解析的外部和未解析的符号

来自分类Dev

LNK2019未解析的QObject外部符号

来自分类Dev

Qt未解析的外部符号LNK2019

来自分类Dev

LNK2019:带有rapidjson的“未解析的外部符号”

来自分类Dev

LNK2019未解析的外部符号SHGetFolderPathW

来自分类Dev

LNK2019:未解析的外部符号-隐式DLL

来自分类Dev

LNK2019未解析的QObject外部符号

来自分类Dev

LNK2019 SHLoadIndirectString的未解析外部符号

来自分类Dev

收到“错误LNK2019:无法解析的外部符号...”

来自分类Dev

C ++ LNK2019错误:无法解析的外部符号

来自分类Dev

Visual Studio的LNK2019错误-无法解析的外部符号

Related 相关文章

  1. 1

    C ++:错误LNK2019:函数中引用的未解析的外部符号__snprintf

  2. 2

    C ++:错误LNK2019:函数_main中引用的未解析的外部符号

  3. 3

    C ++:错误LNK2019:函数_main中引用的未解析的外部符号

  4. 4

    错误21错误LNK2019:无法解析的外部符号:....在函数:...中引用。

  5. 5

    LNK2019 未解析的外部符号 GetMonitorBrightness 在函数 main 中引用

  6. 6

    错误LNK2019:函数main中引用了无法解析的外部符号

  7. 7

    错误LNK2019:函数___tmainCRTStartup中引用了无法解析的外部符号_wWinMain @ 16

  8. 8

    错误LNK2019:函数main中引用了无法解析的外部符号

  9. 9

    使用defalt args时在函数_main中引用的错误LNK2019无法解析的外部符号

  10. 10

    错误:LNK2019:Qt中无法解析的外部符号

  11. 11

    LNK2019未解析的外部符号_CrtDbgReport在函数_CRT_RTC_INIT SDL2中引用

  12. 12

    错误LNK2019:未解析的外部符号“公共:__thiscall RNG :: RNG(unsigned __int64)”(?? 0RNG @@ QAE @ _K @ Z)在函数_main中引用

  13. 13

    尽管在cpp中有定义,但LNK2019构造函数中未解析的外部符号

  14. 14

    Boost文件系统库中未解析的外部符号(错误LNK2019)

  15. 15

    错误LNK2019:无法解析的外部符号:: FindWindow()函数

  16. 16

    LNK2019:函数___tmainCRTStartup中使用DLL引用的未解析的外部符号_main

  17. 17

    Visual Studios C ++代码中的错误。Lab4.obj:错误LNK2019:未解析的外部符号“布尔__cdecl

  18. 18

    LNK2019:C ++ / CLI中无法解析的外部符号

  19. 19

    LNK2019 和 LNK1120 错误,未解析的外部和未解析的符号

  20. 20

    LNK2019未解析的QObject外部符号

  21. 21

    Qt未解析的外部符号LNK2019

  22. 22

    LNK2019:带有rapidjson的“未解析的外部符号”

  23. 23

    LNK2019未解析的外部符号SHGetFolderPathW

  24. 24

    LNK2019:未解析的外部符号-隐式DLL

  25. 25

    LNK2019未解析的QObject外部符号

  26. 26

    LNK2019 SHLoadIndirectString的未解析外部符号

  27. 27

    收到“错误LNK2019:无法解析的外部符号...”

  28. 28

    C ++ LNK2019错误:无法解析的外部符号

  29. 29

    Visual Studio的LNK2019错误-无法解析的外部符号

热门标签

归档