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

  • SEARCH
  • Home
  • 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 8614183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:03:48+00:00 2026-06-12T05:03:48+00:00

When I tried to build a project in Linux, I got Error: undefined symbol

  • 0

When I tried to build a project in Linux, I got Error: undefined symbol clock_gettime. So I figured out that I needed to add -lrt to the build command (gcc). However, now it won’t compile in OS X: ld: library not found for -lrt. I don’t know exactly where this function is getting called as it’s in statically linked code, but it seemed to be working just fine in OS X without librt. The linked code probably uses an alternative behind #if __APPLE__ or something.

Is there any way that I can instruct gcc to only link librt if it’s needed, or if it exists? If not, how do I create a Makefile with OS-specific commands? I’m not using autoconf or anything like it.

The Makefile is rather complex, but here’s the operative part:

CC := g++
# In this line, remove -lrt to compile on OS X
LFLAGS := -lpthread -lrt
CFLAGS := -c -Wall -Iboost_build -Ilibtorrent_build/include -Iinc
OBJDIR := obj
SRCDIR := src
SRC := $(wildcard $(SRCDIR)/*.cpp)
OBJS := $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRC))

# Note that libtorrent is built with a modified jamfile to place the
# libtorrent.a file in a consistent location; otherwise it ends up somewhere
# dependent on build environment.
all : $(OBJS) libtorrent_build boost_build
    $(CC) -o exec $(LFLAGS) \
    $(OBJS) \
    libtorrent_build/bin/libtorrent.a \
    boost_build/stage/lib/libboost_system.a
  • 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-12T05:03:50+00:00Added an answer on June 12, 2026 at 5:03 am

    You could try this:

    LFLAGS := -lpthread
    
    OS := $(shell uname -s)
    ifeq ($(OS),Linux)
    LFLAGS += -lrt
    endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to build vtkMFC project available in vtk-5.8.0\VTK\Examples\GUI\Win32\vtkMFC. When I built that I
when i tried to build my project i am getting this error below as:
I'm working on an embedded Linux project. Our build process makes an image that
In Delphi 2009, how can I build a project using command line. I tried
i downlaoded three20 p31. when i tried to build i got errors in following
First off I'm on Ubuntu linux if that matters. I have a simple project
I have a project that uses autotools. A nice feature of autotools is 'out-of-source'
I'm using Netbeans on Linux (Ubuntu 9.04) to build a C project. How do
I created a DLL project and successfully built it. I then tried to use
I tried to build a very very small .NET app in F#. It just

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.