Recently in the attempt to communicate with the UDT, wrote two simple client and server, but the compile time appeared "error LNK2019: unresolved external symbols" error, in order to summarize later, or to record the solution.
1>------Started Build: Project: Udt_appserver, configuration: Debug Win32------
1> build Start time is 2013/11/11 20:53:08.
1>initializebuildstatus:
1> is creating "Debug\udt_appserver.unsuccessfulbuild" because "AlwaysCreate" is already specified.
1>clcompile:
1> Appserver.cpp
1>resourcecompile:
1> all outputs are up-to-date.
1>manifestresourcecompile:
1> all outputs are up-to-date.
1>api.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:int __thiscall cudtunited::startup (void)" ([EMA Il protected]@ @QAEHXZ) are referenced in
1>channel.obj:error LNK2001: unresolved external symbols [email protected]
1>api.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:int __thiscall cudtunited::startup (void)" ([EMA Il protected]@ @QAEHXZ) are referenced in
1>api.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:int __thiscall cudtunited::cleanup (void)" ([EMA Il protected]@ @QAEHXZ) are referenced in
1>api.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:int __thiscall cudtunited::bind (int,unsigned in T) "([email Protected]@@[email protected]) is referenced
1>channel.obj:error LNK2001: unresolved external symbols [email protected]
1>api.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Private:void __thiscall Cudtunited::updatemux (class CU Dtsocket *,struct sockaddr const *,unsigned INT const *) "([email protected]@@[email protected]@[email Protected]@[email p Rotected]) is referenced in
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:void __thiscall cchannel::open (struct Socka DDR const *) "([email protected]@@[email protected]@@z) is referenced
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:void __thiscall cchannel::open (struct Socka DDR const *) "([email protected]@@[email protected]@@z) is referenced
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:void __thiscall cchannel::open (struct Socka DDR const *) "([email protected]@@[email protected]@@z) is referenced
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:void __thiscall cchannel::open (struct Socka DDR const *) "([email protected]@@[email protected]@@z) is referenced
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Private:void __thiscall cchannel::setudpsockopt ( void) "([email protected]@ @AAEXXZ) is referenced
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in function "Public:void __thiscall cchannel::close (void) const "([email protected]@ @QBEXXZ) is quoted
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:int __thiscall cchannel::getsndbufsize ( void) "([email protected]@ @QAEHXZ) is referenced
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:void __thiscall cchannel::getpeeraddr ( struct sockaddr *) const "([email protected]@@[email protected]@@z) is referenced
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:int __thiscall cchannel::sendto (struct sock Addr Const *,class Cpacket &) const "([email protected]@@[email protected]@[email protected]@@z) is referenced
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:int __thiscall cchannel::sendto (struct sock Addr Const *,class Cpacket &) const "([email protected]@@[email protected]@[email protected]@@z) is referenced
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:int __thiscall cchannel::sendto (struct sock Addr Const *,class Cpacket &) const "([email protected]@@[email protected]@[email protected]@@z) is referenced
1>channel.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Public:int __thiscall cchannel::recvfrom (struct so Ckaddr *,class Cpacket &) const "([email protected]@@[email protected]@[email protected]@@z) is referenced
1>core.obj:error LNK2019: unresolved external symbol [email protected], the symbol in the function "Private:int __thiscall cudt::listen (struct sockaddr *, Class Cpacket &) "([email protected]@@[email protected]@[email protected]@@z) is referenced
1>epoll.obj:error LNK2019: unresolved external symbol [email protected], the symbol in function "Public:int __thiscall cepoll::wait (Int,class std::se T<int,struct std::less<int>,class std::allocator<int> > *,class std::set<int,struct std::less <int>,class std::allocator<int> > *,__int64,class std::set<unsigned int,struct std::less< unsigned int>,class std::allocator<unsigned int> > *,class std::set<unsigned int,struct std::less< unsigned int>,class std::allocator<unsigned int> > *) "(Email protected]@@[email protected][email Protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected ]@[email protected]@[email protected]@[email protected]@[email protected]@z) is referenced in
1>epoll.obj:error LNK2019: unresolved external symbol [email protected], the symbol in function "Public:int __thiscall cepoll::wait (Int,class std::se T<int,struct std::less<int>,class std::allocator<int> > *,class std::set<int,struct std::less <int>,class std::allocator<int> > *,__int64,class std::set<unsigned int,struct std::less< unsigned int>,class std::allocator<unsigned int> > *,class std::set<unsigned int,struct std::less< unsigned int>,class std::allocator<unsigned int> > *) "(Email protected]@@[email protected][email Protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected ]@[email protected]@[email protected]@[email protected]@[email protected]@z) is referenced in
1>f:\c_test\test_udt\debug\udt_appserver.exe:fatal error LNK1120:20 an unresolved external command
1>
1> build failed.
1>
1> used Time 00:00:01.05
========== Generation: Success 0, failure 1, latest 0, skip 0 ==========
Then the individual issues are positioned, and then manually add the individual. h files, found that the symptoms are not the root causes, finally found a solution:
#pragma comment (lib, "Ws2_32.lib")
That is, if you are writing a. cpp or a reference to an. h file, add the line above.
The previous meaning of this sentence is to statically add a Lib file
That is, the library file
The Ws2_32.lib file provides support for the following network-related APIs, and if you use the APIs, you should add Ws2_32.lib to the project (otherwise you will need to load ws2_32.dll dynamically).
This phrase usually appears in network programming, when you need to use the network API functions, you must use this statement to load the Ws2_32.lib library or dynamically load the Ws2_32.dll.
For the specific use of #pragma comment, please refer to the Baidu Encyclopedia: #pragma comment
Error LNK2019: unresolved external symbol