Hi,
I just did this :
and got something like this :
Is it possible to create a “FAT” bernoulli.hpp
which is completely self contained ? Let’s call it bernoulliFAT.cpp
.
Something like : gcc bernoulliFAT.cpp
would produce the same binary output as this compiling / llinking command :
?
So, there are two commands that lead to the bernoulli
executable:
Compiling
g++
-std=c++1y
-pthread
-Wno-sign-compare
-O3
-I src
-I stan/src
-I stan/lib/stan_math/
-I stan/lib/stan_math/lib/eigen_3.3.3
-I stan/lib/stan_math/lib/boost_1.69.0
-I stan/lib/stan_math/lib/sundials_4.1.0/include
-DBOOST_RESULT_OF_USE_TR1
-DBOOST_NO_DECLTYPE
-DBOOST_DISABLE_ASSERTS
-DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION
-c
-x c++
-o examples/bernoulli/bernoulli.o
examples/bernoulli/bernoulli.hpp
Linking :
g++
-std=c++1y
-pthread -Wno-sign-compare
-O3
-I src
-I stan/src
-I stan/lib/stan_math/
-I stan/lib/stan_math/lib/eigen_3.3.3
-I stan/lib/stan_math/lib/boost_1.69.0
-I stan/lib/stan_math/lib/sundials_4.1.0/include
-DBOOST_RESULT_OF_USE_TR1
-DBOOST_NO_DECLTYPE
-DBOOST_DISABLE_ASSERTS
-DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION
examples/bernoulli/bernoulli.o
src/cmdstan/main.o
stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_nvecserial.a
stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_cvodes.a
stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_idas.a
-o examples/bernoulli/bernoulli
So, instead of the above ^ two commands. I would like to produce a BIG BIG BIG C++ file (called bernoulliFAT.cpp
) that contains EVERYTHING as C++ source code ONLY and which can be compile+linked by a single command:
g++ bernoully.fat -o bernoiulli_from_fat
and then bernoiully_from_fat
will be the same binary as examples/bernoulli/bernoulli
and will output this when executed by itself :
and if I type examples/bernoulli/bernoulli_from_fat sample data file=examples/bernoulli/bernoulli.data.R
then it outputs something like :
Is there an easy way to create such an inlined file ?
I was reading this : https://www.toptal.com/c-plus-plus/c-plus-plus-understanding-compilation
but … its not simple…
also, it seems that I can make a .js (or LLVM) runnable stan library (AFAIU) :
if I set this into the local file :
it even gives me a stanc file !
so, i have a stanc
compiled by em++
and one compiled by g++
:
and, this also works :
but I just have not idea what to do with that bin/stanc
now, I am trying this :
which gave me this :
but somehow the resulting .js
file cannot be run with node
it errors out…
anyway … i might come back to this at some point … still does not work :(
if you want to play around with this, here is the docker image that you can pull :
Cheers,
Jozsef