2010-10-17 90 views
0

我試圖在Kubuntu Lucid的Qt Creator中使用clucene-0.9.21b和libcue-1.3.0。 這個代碼是可編譯我可以一起使用CLucene和Cue Sheet Parser嗎?

project.pro

SOURCES += main.cpp 
LIBS += -lcue 
INCLUDEPATH += /usr/include/libcue-1.3/libcue 

的main.cpp

extern "C" { 
#include <libcue.h> 
} 
int main(int argc, char *argv[]) { 
return 0; 
} 

所以是本

project.pro

SOURCES += main.cpp 
LIBS += -clucene 

的main.cpp

#include <CLucene.h> 
int main(int argc, char *argv[]) { 
return 0; 
} 

但不是這一個

project.pro

SOURCES += main.cpp 
LIBS += -lcue \ 
-clucene 
INCLUDEPATH += /usr/include/libcue-1.3/libcue 

的main.cpp

extern "C" { 
#include <libcue.h> 
} 
#include <CLucene.h> 
int main(int argc, char *argv[]) { 
return 0; 
} 

後者生成以下的錯誤:

Running build steps for project project... 
Configuration unchanged, skipping QMake step. 
Starting: /usr/bin/make -w 
make: Entering directory `/home/user/project/project' 
/usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile project.pro 
make: Leaving directory `/home/user/project/project' 
make: Entering directory `/home/user/project/project' 
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/usr/include/libcue-1.3/libcue -I. -o main.o main.cpp 
In file included from /usr/include/sys/stat.h:107, 
from /usr/include/CLucene/StdHeader.h:76, 
from /usr/include/CLucene.h:11, 
from main.cpp:5: 
/usr/include/bits/stat.h:88: error: field ‘st_atim’ has incomplete type 
/usr/include/bits/stat.h:89: error: field ‘st_mtim’ has incomplete type 
/usr/include/bits/stat.h:90: error: field ‘st_ctim’ has incomplete type 
/usr/include/bits/stat.h:149: error: field ‘st_atim’ has incomplete type 
/usr/include/bits/stat.h:150: error: field ‘st_mtim’ has incomplete type 
/usr/include/bits/stat.h:151: error: field ‘st_ctim’ has incomplete type 
main.cpp:6: warning: unused parameter ‘argc’ 
main.cpp:6: warning: unused parameter ‘argv’ 
make: *** [main.o] Error 1 
make: Leaving directory `/home/user/project/project' 
Exited with code 2. 
Error while building project project 
When executing build step 'Make' 

爲什麼這樣以及如何使它工作?

+0

爲什麼編譯你在'libcue.h'周圍放了一個明確的'extern'C''?這可能解釋發生了什麼問題。我不知道這些庫,但包含系統頭文件時似乎出現了問題。 'extern'可能是原因。 – 2010-10-17 10:38:09

+0

這是必要的,因爲libcue是一個C庫。它不會在沒有外部的情況下完全編譯。 – theorist 2010-10-27 14:46:46

+0

與QL Creator在openSUSE 11.3上使用clucene-0.9.21和libcue-1.4相同的結果 – theorist 2010-10-27 14:49:16

回答

0

好的,這次我有機會真正嘗試它。問題似乎是libcue在include文件夾中有一個名爲time.h的文件。所以,如果你使用-I/usr/include/libcue-1.4/libcue進行編譯,那麼你最終會用libcue的time.h而不是libc的。

這個工作對我來說:

extern "C" { 
#include <libcue/libcue.h> 
} 
#include <CLucene.h> 

int main(int argc, char *argv[]) { 
return 0; 
} 

,顯然與-I/usr/include目錄/ libcue-1.4 /,而不是-I/usr/include目錄/ libcue-1.4/libcue

+0

是的,非常感謝!這對我也適用! :-) – theorist 2010-11-02 06:11:15

0

如果交換cue和clucene包含的內容會發生什麼?這可能是包括訂單的問題,我懷疑混合c和C++可能會使包括訂單更重要

+0

沒有任何變化 – theorist 2010-10-29 05:40:37

相關問題