Error while compiling model using cmdstanr on a server

Hi there, I try to use cmdstan installed on a server (unbuntu) by our IT team, and got the following error while compiling the testing model. Do you know how to resolve this issue? Thanks.

file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
mod <- cmdstan_model(file)

Compiling Stan program…
/usr/bin/ld: src/cmdstan/main.o: relocation R_X86_64_32 against `.rodata.str1.8’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make: *** [/tmp/RtmpBPI4Fd/model-5f29146d428c] Error 1
Error: An error occured during compilation! See the message above for more information.

Try adding the -fPIC flag to the compiler options and rebuilding cmdstan:

cpp_options <- list(
cmdstan_make_local(cpp_options = cpp_options)

Then trying your model again


Thanks a lot. Will try and let you know.

Sorry, it was solved right away but I forgot to reply. Thanks a gain.

1 Like