Build shared object while using libraw

My goal ultimately is to convert a .cr3-image to an RGB-array that i can seamlessly pass to an existing python-program. For the C++ to Python-interface i'm using pybind11.

The workhorse-function currently has the basic structure:

    // Read, unpack and process a .cr3-image
    LibRaw RawProcessor;
    RawProcessor.open_file(filename.c_str());
    RawProcessor.unpack();
    RawProcessor.dcraw_process();
    libraw_processed_image_t *img = RawProcessor.dcraw_make_mem_image();
 
    // Convert to OpenCV-Matrix 
    cv::Mat image = cv::Mat(img->height, img->width, CV_8UC3, img->data);
    cv::cvtColor(image, image, cv::COLOR_BGR2RGB);
 
    // Return resulting Matrix
    return image;

Then, there's some pybind11-specific syntax to convert it to a python-module (i suspect that's not relevant here):

PYBIND11_MODULE(example, m) {
    m.doc() = "pybind11-plugin to convert an existing .cr3-image to an RGB-array"; // optional module docstring
    m.def("convert_cr3", &convert_cr3, "Convert a .cr3-image to RGB-array");
    //            ^^function-name     ^^function-reference                 ^^description
}

I tried to compile it two ways: using c++ and using cmake and the result in both cases was:

/usr/bin/ld: //usr/local/lib/libraw.a(utils_libraw.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)
project(cr3_to_python)
 
set(CMAKE_CXX_STANDARD 11)
 
link_libraries(raw)
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_subdirectory(/home/tim/git/pybind11 cmake-build-debug)
pybind11_add_module(cr3_to_python main.cpp)
target_link_libraries(cr3_to_python PRIVATE ${OpenCV_LIBS})

Compile-Command with c++:

c++ -O3 -Wall -shared -std=c++11 -fPIC -I/usr/include/python3.6m/ -I/usr/local/include/opencv4/ (python3 -m pybind11 --includes) main.cpp -o cr3_to_python(python3-config --extension-suffix) -lraw

Why is this error happening? I didn't include any code, that uses stderr, to my knowledge!
I'm happy to give further insights.

Forums: