pybind / pybind/pybind11

[BUG]: relocation R_X86_64_PC32 against symbol `_ZTV10ConfigFile' can not be used when making a shared object; recompile with -fPIC

Open
#4,453 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

Required prerequisites
What version (or hash if on master) of pybind11 are you using?

master

Problem description

When using cmake, the third-party library has interdependence and an error occurs.
Looking forward to your reply.

Errors:

/usr/bin/ld: /home/xxx/lib/libobjMesh.a(objMesh.o): warning: relocation against `_ZTIi@@CXXABI_1.3' in read-only section `.text.unlikely'
 
/usr/bin/ld: /home/xxx/lib/libconfigFile.a(configFile.o): relocation R_X86_64_PC32 against symbol `_ZTV10ConfigFile' can not be used when making a shared object; recompile with -fPIC

Complete cmakelists:

cmake_minimum_required(VERSION 3.4...3.18)
project(corn_deformable)

SET(CMAKE_CXX_STANDARD 11)
SET(SOURCES src/main.cpp src/CornDeform.cpp)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)


add_subdirectory(pybind11)

INCLUDE_DIRECTORIES(
        ${PROJECT_SOURCE_DIR}/include
        ${PROJECT_SOURCE_DIR}/VEGA_FEM_4_0/include
)

LINK_DIRECTORIES(
        ${PROJECT_SOURCE_DIR}/VEGA_FEM_4_0/lib
)


pybind11_add_module(${PROJECT_NAME} ${SOURCES})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC
        -Wl,--start-group
        -lGL -lGLU -lglut -lGLEW
        libbasicAlgorithms.a
        libcamera.a
        libclothBW.a
        libconfigFile.a
        libconstrainedDOFs.a
        libcorotationalLinearFEM.a
        libforceModel.a
        libgetopts.a
        libgraph.a
        libimageIO.a
        libintegrator.a
        libintegratorSparse.a
        libinterpolationCoordinates.a
        libisotropicHyperelasticFEM.a
        liblighting.a
        liblistIO.a
        libmassSpringSystem.a
        libmatrixIO.a
        libmesh.a
        libminivector.a
        libobjMesh.a
        libopenGLHelper.a
        libperformanceCounter.a
        libpolarDecomposition.a
        libsceneObject.a
        libsparseMatrix.a
        libsparseSolver.a
        libstencilForceModel.a
        libstvk.a
        libvolumetricMesh.a
        -Wl,--end-group
        )


# EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a
# define (VERSION_INFO) here.
target_compile_definitions(${PROJECT_NAME}
                           PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})

Reproducible example code

No response

Is this a regression? Put the last known working version here if it is.

Not a regression

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided CMakeLists.txt and the linker diagnostics, then verify how the listed third-party static libraries were built and whether their position-independent-code settings are available. Done would be a confirmed project-side or third-party build cause with a reproducible configuration or documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.