2

Qt 4.6.1

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

sources = ef.cpp

我收到以下错误:

RInside.h: No such file or directory

在此处输入图像描述

然后,当我将 = 替换为 := 时,例如:

sources := ef.cpp

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

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

在此处输入图像描述

从这里: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)
4

1 回答 1

5

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

QT =
CONFIG =

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

于 2012-11-01T09:28:00.743 回答