首页 > 代码库 > 编译Live555出现error LNK2019 error LNK2001

编译Live555出现error LNK2019 error LNK2001

Live555有四个基础库,UsageEnvironment&TaskScheduler,groupsock,liveMedia,BasicUsageEnvironment

,四个基础库都成功编译为lib文件后,我添加了MediaServer想要进行测试

MediaServer需要设置一下下

1、将四个Lib文件拷贝到MediaServer的工程目录下,因为MediaServer应用程序需要使用这几个Lib(明确Lib文件的位置)

2、“项目->属性->配置属性->连接器->输入->附加依赖项”里填写这几个Lib文件名称(告诉项目需要什么Lib文件)

3、将MediaServer工程需要用到的头文件包含进来。


1>Linking...

1>BasicUsageEnvironment.lib(BasicUsageEnvironment.obj) : error LNK2019: unresolved external symbol _initializeWinsockIfNecessary referenced in function "protected: __thiscall BasicUsageEnvironment::BasicUsageEnvironment(class TaskScheduler &)" (??0BasicUsageEnvironment@@IAE@AAVTaskScheduler@@@Z)
1>groupsock.lib(GroupsockHelper.obj) :error LNK2019: unresolved external symbol _initializeWinsockIfNecessary
1>groupsock.lib(NetAddress.obj) : error LNK2019: unresolved external symbol _our_inet_addr referenced in function "public: __thiscall NetAddressList::NetAddressList(char const *)" (??0NetAddressList@@QAE@PBD@Z)
1>groupsock.lib(GroupsockHelper.obj) : error LNK2001: unresolved external symbol _our_inet_addr
1>groupsock.lib(GroupsockHelper.obj) : error LNK2019: unresolved external symbol _our_srandom referenced in function "unsigned int __cdecl ourIPAddress(class UsageEnvironment &)" (?ourIPAddress@@YAIAAVUsageEnvironment@@@Z)
1>groupsock.lib(GroupsockHelper.obj) : error LNK2019: unresolved external symbol _our_random referenced in function "unsigned int __cdecl chooseRandomIPv4SSMAddress(class UsageEnvironment &)" (?chooseRandomIPv4SSMAddress@@YAIAAVUsageEnvironment@@@Z)
1>liveMedia.lib(ProxyServerMediaSession.obj) : error LNK2001: unresolved external symbol _our_random
1>liveMedia.lib(RTCP.obj) : error LNK2001: unresolved external symbol _our_random
1>liveMedia.lib(RTPSink.obj) : error LNK2001: unresolved external symbol _our_random
1>liveMedia.lib(RTSPServer.obj) : error LNK2019: unresolved external symbol _our_random32 referenced in function "protected: void __thiscall RTSPServer::RTSPClientConnection::handleRequestBytes(int)" (?handleRequestBytes@RTSPClientConnection@RTSPServer@@IAEXH@Z)
1>liveMedia.lib(RTPSink.obj) : error LNK2001: unresolved external symbol _our_random32
1>liveMedia.lib(RTPSource.obj) : error LNK2001: unresolved external symbol _our_random32
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

1>../../debug/MediaServer\MediaServer.exe : fatal error LNK1120: 6 unresolved externals

原来添加文件时只添加了.cpp文件,liveMedia和Groupsock中有几个.c文件没有添加进去,使得一些函数或参数没有定义,添加完丢失的.c后继续编译,依旧提示错误:

fatal error C1853: ‘Debug\groupsock.pch‘ precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)

翻译:预编译头文件来自于编译器的以前版本,或者预编译头文件是C++类型而去编译C类型文件

解决办法:找到对应的.c文件,右键——C++——预编译头——选择“不使用预编译头”——重新编译工程,成功