【问题标题】:Error compiling testOnDemandRTSPServer.cpp (From the Live555 libraries)编译 testOnDemandRTSPServer.cpp 时出错(来自 Live555 库)
【发布时间】:2011-07-28 02:48:19
【问题描述】:

我正试图弄清楚如何编译testOnDemandRTSPServer.cpp,正如在 live555 媒体服务器源的 testProgs 目录中找到的那样。我正在使用 Ubuntu 11.04 并安装了 liblivemedia-dev 库。

我已将标头包含(在testOnDemandRTSPServer.cpp 内)修改为:

#include <liveMedia/liveMedia.hh>
#include <BasicUsageEnvironment/BasicUsageEnvironment.hh>

并使用此命令编译:

g++ -lliveMedia -lgroupsock -lBasicUsageEnvironment -lUsageEnvironment testOnDemandRTSPServer.cpp -o RTSPServer

这会导致错误:

In file included from /usr/include/liveMedia/MediaSink.hh:25:0,
             from /usr/include/liveMedia/RTPSink.hh:25,
             from /usr/include/liveMedia/MultiFramedRTPSink.hh:26,
             from /usr/include/liveMedia/AudioRTPSink.hh:25,
             from /usr/include/liveMedia/MPEG1or2AudioRTPSink.hh:25,
             from /usr/include/liveMedia/liveMedia.hh:27,
             from testOnDemandRTSPServer.cpp:21:
/usr/include/liveMedia/FramedSource.hh:25:23: fatal error: NetCommon.h: No such file or directory
compilation terminated.

在这一点上,我想到了一个很好的交易,这只是头文件之间的重定向问题。然后我修改了/usr/include/liveMedia/FramedSource.hh 以使用#include &lt;groupsock/NetCommon.h&gt; 而不是#include "NetCommon.h" - 因为NetCommon.h 位于/usr/include/groupsock/

这很有效,直到我发现了一百万个其他重定向问题,例如:

  • /usr/include/liveMedia/Media.hh:29:22: fatal error: Boolean.hh: No such file or directory
  • /usr/include/liveMedia/Media.hh:33:31: fatal error: UsageEnvironment.hh: No such file or directory
  • 等等……

那么,我是否首先正确链接到 live555 库,还是必须根据需要不断更改标头位置?

更新

所以我继续使用上述方法更改标题位置,但现在我得到了一百万个未定义的引用错误...as shown here(抱歉,这里发布太多)

现在我摸不着头脑,因为原始的 testOnDemandRTSPServer.cpp 编译没有问题(使用 configure/make 方法);而我唯一改变的是在哪里寻找头文件。

【问题讨论】:

    标签: c++ ubuntu compilation linker live555


    【解决方案1】:

    答案

    根本不使用 Ubuntu Packaged 库...而是只编译来自 Live555 website 的源代码。
    在自定义 Makefile 中,这是我用来编译自己的程序和 testOnDemandRTSPServer 的结构:

    LIVE_INCLUDES=-I../UsageEnvironment/include -I../groupsock/include -I../liveMedia/include -I../BasicUsageEnvironment/include
    LIVE_LIBS=../liveMedia/libliveMedia.a ../groupsock/libgroupsock.a ../BasicUsageEnvironment/libBasicUsageEnvironment.a ../UsageEnvironment/libUsageEnvironment.a
    
    g++ $(LIVE_INCLUDES) testOnDemandRTSPServer.c -c
    g++ -o testOnDemandRTSPServer -L. testOnDemandRTSPServer.o $(LIVE_LIBS)
    

    它也解决了未定义的引用错误:P

    【讨论】:

    • 谢谢亚历克斯,这对我也有用。诀窍是 LiveMedia 库需要以正确的顺序排列,并且需要在 GCC 命令行上的主代码之后给出。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多