Closed lentils closed 3 years ago
What is it you are trying to do? Why not just use the binary package from CRAN?
Hi jeroen,
Good question. The goal is to build R packages that are as portable as possible, hence the statically compiled package. At my organization, we host everything internally to avoid unexpected outages by CRAN mirrors. We also write our own R packages for internal use only, so they must be built and hosted outside of CRAN. We use the same process for building both CRAN packages and our own internal-only packages.
For this particular case, we could certainly use CRAN's version, but ideally we can use the same mechanism to build and deploy any package. I suppose part of my question in this issue is whether or not I'm approaching statically compiled packages correctly, in the first place.
Hope the context helps. Thanks again.
@lentils is this still an issue for you?
Hi @sckott,
Thanks for checking in. As far as I can tell, the original problem of not being able to build with -ljq -lonig
remains. Like I said, it's defined in configure
as PKG_LIBS_STATIC
but I can't figure out how to get R to build jqr using that variable without modifying the source directly. Maybe I'm misunderstanding how to configure R's build process properly.
That said, this not as important of an issue for us as it was a few months ago. At this point, I'm mostly looking to satisfy my curiosity. I can't tell if this is a bug or user error on my part! Clearly the package is able to statically linked, since it's that way on CRAN, but I can't reproduce that same build artifact myself.
thanks @lentils - @jeroen can you chime in here. i'm not quite sure how to help on this
Maybe you can try passing them via LIB_DIR?
install.packages('jqr', type = 'source', configure.vars = 'LIB_DIR="/usr/local/lib -ljq -lonig"')
ping @lentils a suggestion from jeroen above
Hello,
I'm trying to build a statically linked version of jqr for MacOS (like what's built on CRAN) and I'm running into an issue with
configure
andPKG_LIBS
used in compilation.First I
brew install jq
, which installsoniguruma
as a dependency. Then I run:R --vanilla CMD install jqr_1.0.0.tar.gz -l /Users/jenkins/test-r-pkg-build --build --preclean
For dynamic linking (ie using
.dylib
), I have no problems and can compile fine. It's only when I try static linking (ie using.a
files) where I run into issue.For static linking, I remove the
.dylib
files for bothlibjq
andlibonig
with the following:Then, when I build, I get the following:
The issue seems to be the fact that
jqr
usesPKG_LIBS=-L/usr/local/lib -ljq
instead ofPKG_LIBS=-L/usr/local/lib -ljq -lonig
. The former is fine when you have dynamic linking becauselibjq.dylib
is dynamically linked tolibonig.dylib
, so the dependency is resolved at runtime. With static linking, the compiler must know to look for and includelibonig
at compile time.I was able to build a statically linked version of
jqr
successfully by overwritingPKG_LIBS
in Makevars, but that isn't a very good solution when you're building lots of packages at once. R seems to recommend using--configure-vars
as proper way to customize package builds.Looking at https://github.com/ropensci/jqr/blob/master/configure#L15 I see you do have the flag I need in your
configure
script, but I don't see any reference to that variable inside the script. This seems like a bug to me.So, my questions are: 1) Is this the right approach statically compile
jqr
? 2) Is this a bug inconfigure
?I'm happy to submit a PR addressing this, but I haven't written too many R packages before. I would expect a fix to include a flag like
--enable-static
thatconfigure
would consume to choose the right value forPKG_LIBS
. Let me know what you think about this approach.Thanks for taking the time to read my question. Appreciate any feedback you have here!
Here's the ouput of
sessionInfo
as well: