R not found - R shared library (/usr/local/lib/R/lib/libR.so) not found. If this is a custom build of R, was it built with the --enable-R-shlib option?

No, it's not that easy. I simply copy paste the libR.so into R shared library, but still can't run R:

R Session Startup Failure Report

RStudio Version

RStudio 2022.07.2+576, "Spotted Wakerobin" (e7373ef8, 2022-09-06) for Ubuntu Bionic

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36

Error message

[No error available]

Process Output

The R session exited with code 2.

Error output:

unable to initialize the JIT


Standard output:

[No output emitted]

Logs

/home/mint/.local/share/rstudio/log/rsession-mint.log

2022-09-30T18:34:42.787742Z [rsession-mint] ERROR R SUICIDE: unable to initialize the JIT; LOGGED FROM: void {anonymous}::rSuicide(const string&) src/cpp/session/SessionMain.cpp:1237
2022-09-30T18:46:05.581321Z [rsession-mint] ERROR R SUICIDE: unable to initialize the JIT; LOGGED FROM: void {anonymous}::rSuicide(const string&) src/cpp/session/SessionMain.cpp:1237
2022-09-30T18:46:05.581321Z [rsession-mint] ERROR R SUICIDE: unable to initialize the JIT; LOGGED FROM: void {anonymous}::rSuicide(const string&) src/cpp/session/SessionMain.cpp:1237

and when trying to reinstall R and do make after extracting the tarball I get this:

make[1]: Entering directory '/home/mint/R-4.2.1'
configuring Java ...
Java interpreter : /usr/bin/java
Java version : 11.0.16
Java home path : /usr/lib/jvm/java-11-openjdk-amd64
Java compiler : not present
Java headers gen.:
Java archive tool:

trying to compile and link a JNI program
detected JNI cpp flags :
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
make[2]: Entering directory '/tmp/Rjavareconf.t7k24u'
gcc -I"/home/mint/R-4.2.1/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c conftest.c -o conftest.o
conftest.c:1:10: fatal error: jni.h: No such file or directory
1 | #include <jni.h>
| ^~~~~~~
compilation terminated.
make[2]: *** [/home/mint/R-4.2.1/etc/Makeconf:168: conftest.o] Error 1
make[2]: Leaving directory '/tmp/Rjavareconf.t7k24u'
Unable to compile a JNI program

JAVA_HOME : /usr/lib/jvm/java-11-openjdk-amd64
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /home/mint/R-4.2.1
Done.

make[1]: Leaving directory '/home/mint/R-4.2.1'