Setting compilation options specified by external scripts
Posted: Thu Feb 24, 2011 3:28 am
Hi,
I'm compiling a project that uses some precompiled library (I'm trying to integrate
R C++ code (see http://www.r-project.org/) in a common C++ project). In order to
compile that library it is required to pass to the g++ linker some options (flags?).
The options (flags) may vary from system to system, so one must call a script (or program)
that replies with the right/specific flags for each system.
I do that writing in (right click on the project name) -> Settings -> Linker -> Options the
following:
and it works. In fact if in a terminal I write:
its replies:
and that is ok. Now, the path to the script may also vary from system to system. In my
case the path is:
from it, the "first part":
is the system specific. This first part of the path can be obtained calling an executable named R that
is exported to the system PATH (when R is installed) trough the following command:
which returns:
So I want to use that in order to make non system specific the "options" line
that I pass to the compiler. I have tried two things. One is to change:
by:
but it doesn't work (I'm not a linux expert). Then I have tried
by means of exporting what R RHOME returns. That is, in:
(right click on project name) -> Settings -> PreBuild
I add the follwong command line to run in the pre-build event:
and then change:
by:
but it also doesn't work.
Which is the right way of do that?
Best Regards
I'm compiling a project that uses some precompiled library (I'm trying to integrate
R C++ code (see http://www.r-project.org/) in a common C++ project). In order to
compile that library it is required to pass to the g++ linker some options (flags?).
The options (flags) may vary from system to system, so one must call a script (or program)
that replies with the right/specific flags for each system.
I do that writing in (right click on the project name) -> Settings -> Linker -> Options the
following:
Code: Select all
`usr/lib64/R/bin/Rscript -e "Rcpp:::LdFlags()"`
Code: Select all
$ /usr/lib64/R/bin/Rscript -e "Rcpp:::LdFlags()"
Code: Select all
-L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib
case the path is:
Code: Select all
/usr/lib64/R/bin/
from it, the "first part":
Code: Select all
/usr/lib64/R/
is exported to the system PATH (when R is installed) trough the following command:
Code: Select all
$ R RHOME
Code: Select all
/usr/lib64/R
that I pass to the compiler. I have tried two things. One is to change:
Code: Select all
`usr/lib64/R/bin/Rscript -e "Rcpp:::LdFlags()"`
Code: Select all
`$(R RHOME)/bin/Rscript -e "Rcpp:::LdFlags()"`
by means of exporting what R RHOME returns. That is, in:
(right click on project name) -> Settings -> PreBuild
I add the follwong command line to run in the pre-build event:
Code: Select all
export R_HOME=$(R RHOME)
Code: Select all
`usr/lib64/R/bin/Rscript -e "Rcpp:::LdFlags()"`
Code: Select all
`$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`
Which is the right way of do that?
Best Regards