2010-11-20 21 views
0

所以我想在我的應用程序中使用LZO。下面是我已經包含了它:問題與LZO

#include "lzoconf.h" 
#include "lzodefs.h" 
#include "lzo1x.h" 
/* portability layer */ 
static const char *progname = NULL; 
#define WANT_LZO_MALLOC 1 
#define WANT_XMALLOC 1 
#include "portab.h" 

然後在應用我做的:

if (lzo_init() != LZO_E_OK) 
{ 
    printf("internal error - lzo_init() failed !!!\n"); 
    printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n"); 
    return 4; 
} 

它編譯OK。編譯期間沒有錯誤或警告。

當我嘗試運行,雖然我的應用程序中,有兩個誤區:

/home/richard/client/src/portab.h:145: undefined reference to `__lzo_align_gap' 

在這一行portab.h哪些點:

if (__lzo_align_gap(p, (lzo_uint) sizeof(lzo_align_t)) != 0) 
{ 
    printf("%s: C library problem: malloc() returned mis-aligned pointer!\n", progname); 
    exit(1); 
} 
return p; 

而且在我的應用程序:

/home/richard/client/src/main.cc:108: undefined reference to `__lzo_init_v2' 

點指向:

if (lzo_init() != LZO_E_OK) 
{ 
    printf("internal error - lzo_init() failed !!!\n"); 
    printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n"); 
    return 4; 
} 

我有我的源目錄中的所有頭文件:

config.h 
lzo1x.h 
lzoconf.h 
lzodefs.h 
miniacc.h 
portab.h 
portab_a.h 

我在做什麼錯?

我正在編譯我的應用程序在Ubuntu 10.10在Anjuta ide。

回答

1

標題是不夠的,你需要鏈接到庫。您是否閱讀過文檔?

+0

是的。但我不知道如何鏈接圖書館。這裏沒有提到。 – 2010-11-20 23:26:03

+0

@Richard:Anjuta IDE有一個教程提到關於「庫路徑」的任何內容嗎?我從來沒有聽說過那個IDE,也不是Linux專家,但是應該在LZO目錄中的某個地方有一些擴展名爲'.a'的文件,對吧?也許在一個名爲'lib'的目錄中? – fredoverflow 2010-11-20 23:31:02

+0

只是一個猜測,但是你的LD_PATH設置指向lzo庫?,爲我們回顯$ LD_PATH? – hhafez 2010-11-20 23:37:18