2

Qt 4.6.1

In the following .pro file, when I use the statement

sources = ef.cpp

I get following errors:

RInside.h: No such file or directory

enter image description here

Then when I replace = with := like:

sources := ef.cpp

the above error vanishes, and I get a new error:

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

enter image description here

From 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.

I wish to understand what's happening here, and what's the solution.

.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)
Community
  • 1
  • 1
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
  • Looks like the change you've already made gets you to the link stage. Do you have a `qMain(int, char**)`? And is it actually being compiled? – cHao Nov 01 '12 at 05:11
  • @cHao I have already posted the only source code that I have. I have not specially written qMain anywhere. If you meant something else, please clarify. – Aquarius_Girl Nov 01 '12 at 05:16
  • What i'm seeing hints to me that the linker can't find the main function. Meaning it either doesn't exist at all, has the wrong name, or is not in any of the files being compiled. Where and how is your main function defined? n If you don't have one, how is this stuff supposed to work? – cHao Nov 01 '12 at 05:23
  • @cHao `If you don't have one, how is this stuff supposed to work? ` You are perhaps getting me wrong. I have the `main` function but I don't have the `qMain` function. The error is different when I replace `:=` with `=`. See OP. – Aquarius_Girl Nov 01 '12 at 05:50

1 Answers1

5

This doesn't look like a Qt project, so you should probably disable linking against Qt libs. Set QT and CONFIG to be empty:

QT =
CONFIG =

If on other hand this is a Qt project that should link against Qt libraries, then the problem is that you're overwriting vital variables, like QMAKE_LIBS and QMAKE_CXXFLAGS. Use +=, not :=. Also, use LIBS, not QMAKE_LIBS.

Nikos C.
  • 50,738
  • 9
  • 71
  • 96