2012-11-01 25 views
1

的Qt 4.6.1:=对比=错误:未定义参照QMAIN(INT,焦炭**)

在下面的pro文件,当我使用语句

sources = ef.cpp 

我得到如下错误:

RInside.h: No such file or directory 

enter image description here

然后当我更换=:=,如:

sources := ef.cpp 

上述错误消失了,我得到一个新的错误:

error: undefined reference to qMain(int, char**) 

enter image description here

从这里:https://stackoverflow.com/a/448939/462608

VARIABLE = value Normal setting of a variable - values within it are recursively expanded when the variable is used, not when it's declared

VARIABLE := value Setting of a variable with simple expansion of the values inside - values within it are expanded at declaration time.

我想了解这里发生了什么,而w帽子是解决方案。

的.cpp

#include <RInside.h> 
int main(int argc, char *argv[]) 
{ 
    RInside R(argc, argv); 

    R["txt"] = "Hello, world!\n"; 

    R.parseEvalQ ("cat(txt)"); 

    exit(0); 
} 

的.pro

TEMPLATE = app 
TARGET  = 
DEPENDPATH += . 
INCLUDEPATH += . 

R_HOME := 'c:/R-2.15.1' 

# Input 
sources = ef.cpp 
programs := $(sources:.cpp=) 

## include headers and libraries for R 
RCPPFLAGS :=  $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config --cppflags) 
RLDFLAGS :=  $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config --ldflags) 
RBLAS  :=  $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config BLAS_LIBS) 
RLAPACK :=  $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config LAPACK_LIBS) 

## include headers and libraries for Rcpp interface classes 
RCPPINCL :=  $(shell echo 'Rcpp:::CxxFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla 

--slave) 
RCPPLIBS :=  $(shell echo 'Rcpp:::LdFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla --slave) 


## include headers and libraries for RInside embedding classes 
RINSIDEINCL :=  $(shell echo 'RInside:::CxxFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla --slave) 
RINSIDELIBS :=  $(shell echo 'RInside:::LdFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla --slave) 


## compiler etc settings used in default make rules 
CXX  := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CXX) 
CPPFLAGS := -Wall $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CPPFLAGS) 
#CXXFLAGS := $(RCPPFLAGS) $(RCPPINCL) $(RINSIDEINCL) $(shell $(R_HOME)/bin/R $(R_ARCH) 

CMD config CXXFLAGS) 
QMAKE_CXXFLAGS := $(RCPPFLAGS) $(RCPPINCL) $(RINSIDEINCL) $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CXXFLAGS) 
LDFLAGS = -s 
QMAKE_LIBS := $(RLDFLAGS) $(RBLAS) $(RLAPACK) $(RINSIDELIBS) $(RCPPLIBS) 
CC   := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CXX) 
+0

看起来你已经做出的改变让你进入链接阶段。你有'qMain(int,char **)'吗?它是否真的被编译? – cHao

+0

@cHao我已经发布了我拥有的唯一源代码。我没有专门写qMain在任何地方。如果你的意思是别的,请澄清。 –

+0

我在看到提示,链接器找不到主要功能。这意味着它根本不存在,名称错误,或者不在正在编译的任何文件中。您的主要功能在哪里以及如何定义? ñ如果你没有一个,这个东西应该如何工作? – cHao

回答

2

这看起来并不像一个Qt项目,所以你应该禁用链接对Qt的库。设置QTCONFIG是空的:

QT = 
CONFIG = 

如果在另一方面,这应该针对Qt库链接的Qt项目,那么问题是,你覆盖重要的变量,如QMAKE_LIBSQMAKE_CXXFLAGS。使用+=,而不是:=。此外,请使用LIBS,而不是QMAKE_LIBS