【问题标题】:Just trying to call a function of a library只是试图调用一个库的函数
【发布时间】:2012-04-06 17:29:45
【问题描述】:

我在/root_project/main.cpp 中有这样的代码:

#include "theoraplayer/TheoraVideoClip.h"

unsigned int tex_id;
TheoraVideoManager* mgr;
TheoraVideoClip* clip;
std::string window_name="glut_player";
bool started=1;
int window_w=800,window_h=600;

void draw()
{
    glBindTexture(GL_TEXTURE_2D,tex_id);

    TheoraVideoFrame* f=clip->getNextFrame();   //this gives an error!!!
    if (f)
    {

TheoraVideoClip.h 文件位于/root_project/include/theoraplayer/

TheoraVideoClip.h 里面有这个:

TheoraVideoFrame* getNextFrame();

当我尝试使用 g++ -o app main.cpp -lGL -lglut -lGLU 进行编译时 我遇到了这个错误:

main.cpp:(.text+0xac2): 未定义的引用 `TheoraVideoClip::getNextFrame()'

有人知道为什么吗?

Ubuntu 11.10

【问题讨论】:

    标签: c++ ogg-theora


    【解决方案1】:

    您还需要链接到libtheoraplayer

    【讨论】:

    • 在哪里?在命令中编译?我做了'g++ -o app main.cpp -lGL -lglut -lGLU -libtheoraplayer' 但它说'/usr/bin/ld: 找不到-libtheoraplayer'。
    • @tirengarfio : 那应该是-ltheoraplayer,并且由于您似乎将库放在非默认位置,您可能还需要使用-L 来指定该位置。
    • 我找到了这个链接cplusplus.com/forum/beginner/24862,现在我正在写这个:g++ -o app main.cpp -lGL -lglut -lGLU -ltheora -ltheoradec 但错误是一样的..跨度>
    • @tirengarfio :您仍然缺少 -L 来告诉链接器在哪里可以找到库。 (我假设您实际上 构建了 库,而不仅仅是拥有源代码...)
    • 我认为图书馆已经建立,因为如果我写 -ltheorafoobar 它说它找不到那个图书馆..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    • 2011-09-08
    • 2016-11-16
    • 2011-12-26
    • 1970-01-01
    相关资源
    最近更新 更多