Skip to content

sqlite3 library cannot be built on Linux when dynamically linked  #167

Closed
@ChristopherCieslak

Description

@ChristopherCieslak

We are trying to create a shared library which used sqlite3 and obtain the following error only on the Linux platform:

/usr/bin/x86_64-linux-gnu-ld: ../ThirdParty/SQLiteCpp/sqlite3/libsqlite3.a(sqlite3.c.o): relocation R_X86_64_PC32 against symbol `sqlite3_mutex_enter' can not be used when making a shared object; recompile with -fPIC

It works well when adding those lines:

if (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
set_target_properties(sqlite3 PROPERTIES COMPILE_FLAGS "-fPIC")
endif()

The task consists of adding those above lines into the CMakeLists.txt which builds the target sqlite3.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions