Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8922739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:55:17+00:00 2026-06-15T06:55:17+00:00

I am trying to make a shared library linked with a static version of

  • 0

I am trying to make a shared library linked with a static version of librt. Currently I am doing this:

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
ADD_LIBRARY(memtrace SHARED memtrace.c)
ADD_LIBRARY(lib_real_time STATIC IMPORTED)
SET_TARGET_PROPERTIES(lib_real_time PROPERTIES IMPORTED_LOCATION /usr/lib/x86_64-linux-gnu/librt.a)
TARGET_LINK_LIBRARIES(memtrace lib_real_time)

But I do not want to specify the path like this. Since librt is always in standard paths, I’d rather have cmake find it. Like in gcc I would only specify -lrt.
When I try to do this using this cmake file:

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
ADD_LIBRARY(memtrace SHARED memtrace.c)
TARGET_LINK_LIBRARIES(memtrace rt)

It will link memtrace with the dynamic version of librt which is not what I want!!

How can I link with the static version of librt without mentioning its full path?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:55:18+00:00Added an answer on June 15, 2026 at 6:55 am

    To link with the static version of the library, just add “.a” extension to it’s name:

    TARGET_LINK_LIBRARIES(memtrace rt.a)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a C shared library. I'm a newbie in Matlab, so
I'm trying to create a shared library version of praatlib . The code itself
I am trying to modify this shared library (with .so) extension on Linux. I
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
I've been trying to make some applications which all rely on the same library,
I'm trying to make simplest so library. #include <stdio.h> void PutLoLoLo(){ puts(Lololo); } compiling
What I am trying to do – Make a JNI call to a shared
I'm trying to create a project as a shared library in OS X using
I am confused If I am doing something wrong while using the static library.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.