The command line compiles the link, the LNK2019 error occurs, how to solve?

xiaoxiao2021-03-06  17

Back Home - Current Index -

Main topic: Command line compile link, there is an LNK2019 error, how to solve it? Compile the link in the Visual Studio environment, but I have the following error in the command line mode:

/out:test01.exe

TEST01.OBJ

TEST01.OBJ: ERROR LNK2019: Unable to resolve external symbol __imp__messageboxa @ 16, the symbol is

Function _MessageBoxPrintf is referenced

TEST01.OBJ: ERROR LNK2019: Unable to resolve external symbol __imp__getsystemmetrics @ 4, this character

No. in the function _winmain @ 16

TEST01.EXE: Fatal Error LNK1120: 2 unable to resolve external commands

How can I determine the connection parameters to link correctly? ? ? ? ?

The following is what I found in MSDN:

External symbol "Symbol" that cannot be parsed, this symbol is referenced in the function "function"

Undefined external symbols (Symbol) are found in the function. To resolve this error, provide symbol definition or removing the code that references it.

Please see the example below:

Extern INT I;

Extern void g ();

Void f ()

{

i ;

g ();

}

int main ()

{

}

If I and G are defined in a file included in the generation, the linker will generate the LNK2019. These definitions can be added, and the method is to include these defined source code files to be part of the compilation. Or pass through the .ObJ or .lib file containing these definitions to the linker.

For C projects upgraded from earlier versions to the current version, if __unicode and the entry point is WinMain, you need to change the name of the entry point function to _twinmain or _tmain.

The common problems leading to the LNK2019 are:

The symbol declaration contains spelling errors, so that the symbol declaration is different from the symbol definition.

Use a function, but the type or quantity of its parameters does not match the function definition.

Function declaration uses and function definitions in use in use (__cdecl, __ stdcall or __fastcall).

The symbol definition is in a file compiled as a C program, and the symbol is declared in the C file without Extern "C" modifiers. In this case, please modify the declaration, for example not use:

Extern INT I;

Extern void g ();

Use:

EXTERN "C" INT I;

EXTERN "C" Void g ();

Similarly, if the symbol will be defined in the C file used by the C program, use Extern "C" in the definition.

The symbol is defined as static, but will be referenced outside the file later.

No static class members are defined. For example, you should separately define the member variables in the following declarations SI:

#include

Struct x {

Static int Si;

}

// int x :: si = 0; // uncomment this line to resolve

void main ()

{

X * px = new x [2];

Printf ("/ n% d", px [0] .si); // lnk2019

}

/ Verbose Link Option Helps you view the files referenced by the linker. The Dumpbin utility / export and / symbols options can also help you view symbols defined in the DLL and object / library files. This problem has been bombed