:= versus = error:对qMain的未定义引用(int,char **)

时间:2012-11-01 05:06:14

标签: c++ windows qt makefile

Qt 4.6.1

在以下.pro文件中,当我使用语句

sources = ef.cpp

我收到以下错误:

RInside.h: No such file or directory

enter image description here

然后当我替换= with:= like:

sources := ef.cpp

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

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

enter image description here

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

  

VARIABLE = value变量的正常设置 - 其中的值为   在使用变量时递归扩展,而不是在声明

时      

VARIABLE:= value通过简单扩展设置变量   里面的值 - 其中的值在声明时间扩展。

我希望了解这里发生了什么,以及解决方案是什么。

的.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)

1 个答案:

答案 0 :(得分:2)

这看起来不像Qt项目,因此您应该禁用与Qt库的链接。将QTCONFIG设为空:

QT =
CONFIG =

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