Cmake - Relocation error at runtime when running in server

Viewed 29

I started with C and C++ a few days ago and I'm losing my mind with this problem. I wrote and compiled a program in C++ using cmake in a Windows Subsystem for Linux (WSL, Ubuntu). The program opens a CSV file, does some filtering and streams out the result as a JSON string. I need to process very fast some csv files in my website, which is hosted by Bluehost, so I thought I could make something in C++ and run it from php with the exec() function. The server uses Linux and php for the backend.

  • Before going deeper into C++ I compiled a simple program that prints "Hello world!" using printf() and tested it with exec() in the server. It worked fine.

  • Then I spent some time on C++ and got an executable that works perfectly when I run it in my own device (WSL).

  • Finally I upload to the server the executable and all the libraries (listed with ldd), except linux-vdso.so.1, and try to run the program. All the files are in the same directory since I can't access the libs of the server. It throws the following error:

./lib/esp_query: relocation error: /lib/libpthread.so.0: symbol __tunable_get_val, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference"

Both libpthread.so.0 and ld-linux-x86-64.so.2 are libraries that the command ldd listed and I uploaded to the server. Before that, I tried to run a simple "Hello world!" example with printf in the server and it worked fine, so I know I can run this kind of files in the server and the c++ code isn't the problem since it worked fine in my device.

I think there's a problem with the libraries, but I'm unable to find where the problem is and a way to fix it. This is the CMakeLists.txt:

SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH $ORIGIN)

cmake_minimum_required(VERSION 3.16)
project(esp_query)

set(CMAKE_CXX_STANDARD 17)

find_package(DataFrame REQUIRED CONFIG)

add_executable(esp_query esp_query.cc)

target_link_libraries(esp_query PRIVATE DataFrame Threads::Threads)
target_compile_options(esp_query
    PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/bigobj>
)

I've been a couple of days looking for a fix, but I didn't find anything like that in Google or in other similar questions in this site. Can you help me point out where's the error and how can I fix it, please?

0 Answers
Related