2014-02-14 69 views
1

我是使用make的新手,我嘗試運行此處給出的Qt密度演示的RInside示例:http://dirk.eddelbuettel.com/blog/2011/03/25/。我已保存代碼到下列文件:RInside編譯:制定目標

的main.cpp 的Makefile qtdensity.cpp 包括/ qtdensity.h

我運行Ubuntu 13.10,我已經安裝了R,RCPP和內部。當我去到終端,運行

> make -f Makefile 

我得到的錯誤

make: *** No targets. Stop. 

請讓我知道如何着手。

謝謝


我看不出怎麼問的後續行動的第一個答案,所以我不得不延長我的問題:

我剛纔創建的文件,並能在main.cpp中,qtdensity.cpp,qtdensity.h運行的qmake和qtdensity.pro其工作,但,當我試圖運行make,我得到以下錯誤:

大量的R - 相關錯誤...

qtdensity.cpp:(.text+0x53a): undefined reference to `Rf_mkString' 
qtdensity.cpp:(.text+0x54e): undefined reference to `Rf_install' 
qtdensity.cpp:(.text+0x559): undefined reference to `Rf_findVarInFrame' 
qtdensity.cpp:(.text+0x560): undefined reference to `R_UnboundValue' 
... 

qtdensity.cpp:(.text.startup+0x2a5): undefined reference to `R_NaReal' 
qtdensity.cpp:(.text.startup+0x2b2): undefined reference to `R_NaN' 
main.o: In function `_GLOBAL__sub_I_main': 
main.cpp:(.text.startup+0x2a5): undefined reference to `R_NaReal' 
main.cpp:(.text.startup+0x2b2): undefined reference to `R_NaN' 
main.o: In function `main': 
main.cpp:(.text.startup+0x352): undefined reference to `RInside::RInside(int, char const* const*, bool, bool, bool)' 
main.cpp:(.text.startup+0x397): undefined reference to `RInside::~RInside()' 
main.cpp:(.text.startup+0x3b3): undefined reference to `RInside::~RInside()' 
moc_qtdensity.o: In function `_GLOBAL__sub_I__ZN9QtDensity18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv': 
moc_qtdensity.cpp:(.text.startup+0x2a5): undefined reference to `R_NaReal' 
moc_qtdensity.cpp:(.text.startup+0x2b2): undefined reference to `R_NaN' 
collect2: error: ld returned 1 exit status 
make: *** [qdensity] Error 1 
+0

它不具有R或RInside鏈接。也許你的系統是非標準的。正如我向你展示的 - 在這裏工作。 –

回答

0

Qt的例子不同,因爲它使用Qt。您需要通過.pro文件創建Makefile本身來始終始終。證人:

[email protected]:~/git/rinside/inst/examples/qt$ ls -l  ## no Makefile 
total 28 
drwxrwxr-x 2 edd edd 4096 Dec 27 18:38 cmake 
-rw-rw-r-- 1 edd edd 518 Dec 27 18:38 main.cpp 
-rw-rw-r-- 1 edd edd 5953 Dec 27 18:38 qtdensity.cpp 
-rw-rw-r-- 1 edd edd 1532 Dec 27 18:38 qtdensity.h 
-rw-rw-r-- 1 edd edd 2378 Feb 11 20:14 qtdensity.pro 
-rw-rw-r-- 1 edd edd 887 Dec 27 18:38 README 
[email protected]:~/git/rinside/inst/examples/qt$ qmake  ## creates Makefile 
[email protected]:~/git/rinside/inst/examples/qt$ make 
g++ -c -m64 -pipe -I/usr/share/R/include [... lots and lots omitted ...] 
g++ -m64 -Wl,-O1 -o qtdensity qtdensity.o main.o moc_qtdensity.o [....] 
[email protected]:~/git/rinside/inst/examples/qt$ ls -l qtdensity 
-rwxrwxr-x 1 edd edd 76666 Feb 14 15:02 qtdensity 
[email protected]:~/git/rinside/inst/examples/qt$ 

當然自述此目錄中還描述了 ...