RStudio Server compile error on arm64 machine?

When trying to compile Studio Server from source, I get the following error (compiled using the one given by INSTALL):

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
/home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/PQ_LIB
    linked by target "rstudio-core" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rstudio-core-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rserver-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server
    linked by target "rserver" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server
/home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/SQLITE_LIB
    linked by target "rstudio-core" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rstudio-core-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rserver-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server
    linked by target "rserver" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server
SOCI_POSTGRESQL_LIB
    linked by target "rstudio-core" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rstudio-core-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rserver-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server
    linked by target "rserver" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server
SOCI_SQLITE_LIB
    linked by target "rstudio-core" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rstudio-core-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rserver-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server
    linked by target "rserver" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

The version I'm trying to compile is 2022-07.2, and the R version is 4.2.1 which is also build from source with additional option as following:

--with-x=no --enable-R-shlib

Anyone have an idea how this may be solved? I've looked around and hasn't find any similar.

I think you need to install SOCI first (since they do not bundle an arm64 version), also you need to install some dependencies like sqlite3, libpq and postgresql client.

http://soci.sourceforge.net/doc/master/installation/

In case you are not aware, there are experimental arm64 builds from RStudio itself.

https://dailies.rstudio.com/rstudio/elsbeth-geranium/

Thanks for your quick reply.

I looked into the INSTALL instruction file and found that the Qt 5.12.8 is only required for Desktop version and in the relevant install-dependencies-* file that fake root and postgresql-devel is only required fir Qt so I didn't install that. So currently I have sqlite3 installed but no libpq nor postgresql installed. But yes, now I have sqlite-devel, libpq-devel and postgresql installed and I have only the latter two error (SOCI_POSTGRESQL_LIB and SOCI_SQLITE_LIB) guys I need to install the devel lib of them.

I checked the arm version from your link but it doesn't have RedHat 8 version which I think I'm running on (Mine is Oracle Linux 8 which appears to be a modified version of RedHat 8).

After reconfiguring SOCI build file it appears there are SOCI_POSTGRESQL_LIB and SOCI_SQLITE_LIB, but I still get the error for building RStudio Server. See following:

$ cmake .. -DRSTUDIO_TARGET=Server -DCMAKE_BUILD_TYPE=Release
-- Building RStudio 2022.09.999-dev+999
-- Machine architecture: aarch64
-- CMake build type: Release
-- Desktop builds not currently supported on aarch64; disabling RSTUDIO_DESKTOP
fatal: not a git repository (or any of the parent directories): .git
-- quarto does not yet support aarch64 builds of Linux; disabling quarto
-- Using RStudio tools root: /opt/rstudio-tools/aarch64
-- Configured to build GWT
-- Using GWT module: org.rstudio.studio.RStudio
-- Using ant: /usr/bin/ant
-- Configured to install GWT
-- Using RStudio-provided Boost 1.78.0
-- Crashpad not yet supported on aarch64 Linux machines; disabling Crashpad
-- Crashpad integration disabled via build parameters
-- SOCI libraries found under /opt/rstudio-tools/aarch64/soci-4.0.3/build/lib
-- Module support is disabled.
-- Version: 8.1.1
-- Build type: Release
-- CXX_STANDARD: 11
-- Required features: cxx_variadic_templates
-- Configured to build SERVER
-- Found R: /usr/local/lib/R
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
SOCI_POSTGRESQL_LIB
    linked by target "rstudio-core" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rstudio-core-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rserver-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server
    linked by target "rserver" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server
SOCI_SQLITE_LIB
    linked by target "rstudio-core" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rstudio-core-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/core
    linked by target "rserver-tests" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server
    linked by target "rserver" in directory /home/opc/RStudioServer/rstudio-rstudio-53277fe/src/cpp/server

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

Moreover, neither of the 4 target mentioned in the error message was found under the respective directory (guess that's what NOT FOUND means?).

Can you give more detail about this?

Sure, the SOCI build file:

$ cmake -G "Unix Makefiles" -DWITH_BOOST=OFF -DWITH_ORACLE=OFF -WITH_POSTGRESQL=TRUE -SOCI_POSTGRESQL=TRUE -WITH_SQLITE3=TRUE -SOCI_SQLITE3=TRUE ..
-- gcc / clang visibility enabled
-- Configuring SOCI: 
-- SOCI_VERSION                             = 4.0.3 
-- SOCI_ABI_VERSION                         = 4.0 
-- SOCI_SHARED                              = ON 
-- SOCI_STATIC                              = ON 
-- SOCI_TESTS                               = ON 
-- SOCI_ASAN                                = OFF 
-- SOCI_CXX11                               = OFF 
-- LIB_SUFFIX                               =  
-- Looking for SOCI dependencies: 
-- Threads: 
-- CMAKE_THREAD_LIBS_INIT                   = -lpthread 
-- Boost: disabled, since WITH_BOOST=OFF 
-- MySQL: 
-- MySQL not found.
-- MySQL Embedded not found.
-- WARNING: MySQL libraries not found, some features will be disabled. 
-- ODBC: 
-- WARNING: ODBC libraries not found, some features will be disabled. 
-- Oracle: disabled, since WITH_ORACLE=OFF 
-- PostgreSQL: 
-- POSTGRESQL_INCLUDE_DIRS                  = /usr/include 
-- POSTGRESQL_LIBRARIES                     = /usr/lib64/libpq.so 
-- POSTGRESQL_VERSION                       = 13.5 
-- SQLite3: 
CMake Warning (dev) at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (SQLITE3)
  does not match the name of the calling package (SQLite3).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/modules/FindSQLite3.cmake:57 (find_package_handle_standard_args)
  cmake/dependencies/SQLite3.cmake:3 (find_package)
  cmake/SociDependencies.cmake:79 (include)
  CMakeLists.txt:129 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- SQLITE3_INCLUDE_DIR                      = /usr/bin 
-- SQLITE3_LIBRARIES                        = /usr/lib64/libsqlite3.so 
-- Firebird: 
-- SOCI_FIREBIRD_EMBEDDED                   = OFF 
-- WARNING: Firebird libraries not found, some features will be disabled. 
-- DB2: 
-- WARNING: DB2 libraries not found, some features will be disabled. 
-- Configuring SOCI core library: 
-- SOCI_CORE_TARGET                         = soci_core 
-- SOCI_CORE_TARGET_OUTPUT_NAME             = soci_core 
-- SOCI_CORE_DEPS_LIBS                      = -lpthread /usr/lib64/libdl.so 
-- SOCI_CORE_INCLUDE_DIRS                   = /home/opc/SOCI/soci-4.0.3/build /home/opc/SOCI/soci-4.0.3/include /home/opc/SOCI/soci-4.0.3/build/include /home/opc/SOCI/soci-4.0.3/include/private /home/opc/SOCI/soci-4.0.3/build/src/core 
-- WITH_BOOST                               = OFF 
-- COMPILE_DEFINITIONS                      = SOCI_ABI_VERSION="4.0" HAVE_DL=1 SOCI_LIB_PREFIX="libsoci_" SOCI_LIB_SUFFIX=".so" SOCI_DEBUG_POSTFIX="" 
-- 
-- Configuring SOCI backend libraries: 
-- MySQL not found.
-- MySQL Embedded not found.
CMake Warning (dev) at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (SQLITE3)
  does not match the name of the calling package (SQLite3).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/modules/FindSQLite3.cmake:57 (find_package_handle_standard_args)
  src/backends/CMakeLists.txt:17 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Empty - SOCI backend skeleton for new backends development 
-- SOCI_EMPTY                               = ON 
-- SOCI_EMPTY_TARGET                        = soci_empty 
-- SOCI_EMPTY_OUTPUT_NAME                   = soci_empty 
-- SOCI_EMPTY_COMPILE_DEFINITIONS           = SOCI_ABI_VERSION="4.0" HAVE_DL=1 
-- SOCI_EMPTY_INCLUDE_DIRECTORIES           = /home/opc/SOCI/soci-4.0.3/build /home/opc/SOCI/soci-4.0.3/include /home/opc/SOCI/soci-4.0.3/build/include /home/opc/SOCI/soci-4.0.3/include/private /home/opc/SOCI/soci-4.0.3/include/private 
-- PostgreSQL - SOCI backend for PostgreSQL 
-- SOCI_POSTGRESQL                          = ON 
-- SOCI_POSTGRESQL_TARGET                   = soci_postgresql 
-- SOCI_POSTGRESQL_OUTPUT_NAME              = soci_postgresql 
-- SOCI_POSTGRESQL_COMPILE_DEFINITIONS      = SOCI_ABI_VERSION="4.0" HAVE_DL=1 
-- SOCI_POSTGRESQL_INCLUDE_DIRECTORIES      = /home/opc/SOCI/soci-4.0.3/build /home/opc/SOCI/soci-4.0.3/include /home/opc/SOCI/soci-4.0.3/build/include /home/opc/SOCI/soci-4.0.3/include/private /home/opc/SOCI/soci-4.0.3/include/private /usr/include /usr/include 
-- SOCI_POSTGRESQL_NOSINLGEROWMODE          =  
-- SQLite3 - SOCI backend for SQLite 3 
-- SOCI_SQLITE3                             = ON 
-- SOCI_SQLITE3_TARGET                      = soci_sqlite3 
-- SOCI_SQLITE3_OUTPUT_NAME                 = soci_sqlite3 
-- SOCI_SQLITE3_COMPILE_DEFINITIONS         = SOCI_ABI_VERSION="4.0" HAVE_DL=1 
-- SOCI_SQLITE3_INCLUDE_DIRECTORIES         = /home/opc/SOCI/soci-4.0.3/build /home/opc/SOCI/soci-4.0.3/include /home/opc/SOCI/soci-4.0.3/build/include /home/opc/SOCI/soci-4.0.3/include/private /home/opc/SOCI/soci-4.0.3/include/private /usr/bin 
-- 
-- Configuring SOCI tests: 
-- SOCI_EMPTY_TEST_CONNSTR                  = dummy
-- MS Access test disabled on non-Windows platform
-- ODBC DB2 test disabled.
-- SOCI_POSTGRESQL_TEST_CONNSTR             = dbname=soci_test
-- SOCI_SQLITE3_TEST_CONNSTR                = :memory:
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/opc/SOCI/soci-4.0.3/build

This is not writing the executables into the correct folder.

Take a look at the bash script that RStudio uses to install SOCI

But when make install it has write the file in /usr/local/include, see:

-- Up-to-date: /usr/local/include/soci/postgresql/soci-postgresql.h
-- Up-to-date: /usr/local/lib64/libsoci_postgresql.so.4.0.3
-- Up-to-date: /usr/local/lib64/libsoci_postgresql.so.4.0
-- Up-to-date: /usr/local/lib64/libsoci_postgresql.so
-- Up-to-date: /usr/local/lib64/libsoci_postgresql.a
-- Up-to-date: /usr/local/include/soci/sqlite3/soci-sqlite3.h
-- Up-to-date: /usr/local/lib64/libsoci_sqlite3.so.4.0.3
-- Up-to-date: /usr/local/lib64/libsoci_sqlite3.so.4.0
-- Up-to-date: /usr/local/lib64/libsoci_sqlite3.so
-- Up-to-date: /usr/local/lib64/libsoci_sqlite3.a

After looking into the file, I found that RStudio use a custom path to hold the SOCI library, which is under $RSTUDIO_TOOLS_ROOT/soci-4.0.3/build/. But I couldn't find anywhere which directory $RSTUDIO_TOOLS_ROOT is referring to. Do you have any idea?
btw, I checked $RSTUDIO_BUILD_DIR/../dependencies/tools/rstudio-tools.* files and they didn't have such variable.

rPi4

After a few initial errors, RStudio Server got installed on rPI-400 SBC

Shiny-Server is giving "
An error has occurred. Check your logs or contact the app author for clarification."

I rerun the cmake, and found that RStudio actually has found the SOCI library:

-- SOCI libraries found under /opt/rstudio-tools/aarch64/soci-4.0.3/build/lib
-- Module support is disabled.
-- Version: 8.1.1

But it has disabled the module.
Under the /opt/rstudio-tools/aarch64/soci-4.0.3/build/lib, I found only the lib of following:

libsoci_core.a
libsoci_core.so -> libsoci_core.so.4.0
libsoci_core.so.4.0 -> libsoci_core.so.4.0.3
libsoci_core.so.4.0.3

Should I then just make alias under this directory to reference the respective lib (libsoci_postgresql.a and libsoci_sqlite3.a of the SOCI build from source)?

----UPDATE----
So creating symlink to /opt/rstudio-tools/aarch64/soci-4.0.3/build/lib/did not work. And retry with hard link works. However, during installing, error related to SOCI library occurred again with libsoci_sqlite3.a:

[ 81%] Linking CXX executable rsession
/bin/ld: /opt/rstudio-tools/aarch64/soci-4.0.3/build/lib/libsoci_sqlite3.a(statement.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `isspace@@GLIBC_2.17' which may bind externally can not be used when making a shared object; recompile with -fPIC
/bin/ld: /opt/rstudio-tools/aarch64/soci-4.0.3/build/lib/libsoci_sqlite3.a(statement.cpp.o)(.text+0x21c8): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `isspace@@GLIBC_2.17'
/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/cpp/session/CMakeFiles/rsession.dir/build.make:4174: src/cpp/session/rsession] Error 1
make[1]: *** [CMakeFiles/Makefile2:793: src/cpp/session/CMakeFiles/rsession.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

---- Update to the installing ----
I thought it might be that I didn't copy the *.so file with the same filename, so I hard linked the rest of the postgresql and sqlite3 library that also exist in the golbal library (/usr/local/lib64/ to the RStudio intended dir, and changed the ownership to the same as that libsoci_core.* have, but the install process still return the error:

/bin/ld: /opt/rstudio-tools/aarch64/soci-4.0.3/build/lib/libsoci_sqlite3.a(statement.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `isspace@@GLIBC_2.17' which may bind externally can not be used when making a shared object; recompile with -fPIC
/bin/ld: /opt/rstudio-tools/aarch64/soci-4.0.3/build/lib/libsoci_sqlite3.a(statement.cpp.o)(.text+0x21c8): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `isspace@@GLIBC_2.17'
/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/cpp/session/CMakeFiles/rsession.dir/build.make:4174: src/cpp/session/rsession] Error 1
make[1]: *** [CMakeFiles/Makefile2:793: src/cpp/session/CMakeFiles/rsession.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

I noticed that the link was not good in /bin/ld, should I instead of making hard link, just duplicate the file?

BTW, I don't think that was related, since it is related to /bin/ld, which is a symlink of another (/etc/alternatives/ld), and eventually linked to the file /usr/bin/ld.bfd.

It seems you haven't compiled SOCI libraries with the required options, use the same compiling options the RStudio's installation script does.

After checking the script, it seems it compiles from source (although they use their own copy of the source files) so it should also compile on arm64. I would try running that script manually to see where it fails. Sadly I can't try any of these myself since I don't have powerful enough arm hardware.

For Raspberry Pi hardware you can follow this blog article

We can probably fix that -- let me see if I can get those added to our build system.

Thanks! I will still try what @andresrcs says to recompile the SOCI library with some additional options, and see what that does.

Well, I actually not quite sure if my current system is based on RedHat 8 tho, it is Oracle Linux 8.5 and I forgot where I saw RedHat and system version 8 when compiling some other softwares. That's why I think it is based on RedHat 8, although oracle officially referred it as "a fully CentOS compatible alternative" only.

Hum, funny thing is that -fPIC option is not recognised when recompiling the SOCI. Am I wrong here?

Builds are live if you want to try 'em --

Desktop: RedHat 8

Server: RedHat 8

Yes! It is partially up and running. I can access to the login window via browser, although I couldn't actually access the application. It doesn't recognise the user created by useradd not even by restarting the rstudio-server. I could validate with sudo rstudio-server validate-installation because it said I need to stop it (which is stopped).

--off-topic--
When trying to add ssl support, the server return that ssl-enabled set in /etc/rstudio/rserver.conf is not a recognised option
And there is no /usr/lib/rstudio-server/bin/pamtester for validating the auth.

Thank you.
Reference to the blog post is given here Shiny Server on 64bit Raspberry Pi OS - Raspberry Pi Forums

1 Like