Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
How to deploy a shared library with cmake on Linux

I have shared library called "libmylib.so" which sits inside a folder "LIBS" outside my application source directory. To link the library to my main executable, I'm using the following CMake commands:

set(LIBS_FOLDER "${CMAKE_SOURCE_DIR}/../LIBS")
find_library(MYLIB NAMES mylib libmylib mylib.dll HINTS ${LIBS_FOLDER})

target_link_libraries(MyApp PUBLIC ${MYLIB})

This works well on both Linux and Windows, however on Linux when I deploy my application the executable links to mylib using its absolute path. Indeed, running ldd MyApp shows that it is linked to:

libmylib.so => /absolute_path_to_libs_dir/libmylib.so (0x00007f9dae78f000)

This is obviously a problem since I can't deploy this to any environment. How can I get around this problem? Is there way to link and deploy the shared library correctly?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!