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 8320861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:48:40+00:00 2026-06-08T22:48:40+00:00

I recently developed a project in C which makes use of the function clock_gettime()

  • 0

I recently developed a project in C which makes use of the function clock_gettime() in linux. The linking for this on my Ubuntu desktop is achieved using the linker flag:

gcc -lrt foo.c

I was excited to read that I could cross-compile my project for the Android in the post below.

http://benno.id.au/blog/2007/11/13/android-native-apps

I’ve tried this on trivial projects though using the command:

arm-linux-gnueabi-gcc -static foo.c -o foo

Rather than the command:

arm-none-linux-gnueabi-gcc -static foo.c -o foo

referred to in the link, and they do indeed compile and link fine, but when I try with my project requiring clock_gettime() and the linking:

-ltr

It fails with:

undefined reference to `clock_gettime'

I’ve read that library specified by -lrt doesn’t exist for the Android, and I’ve found posts other places claiming that folks are using clock_gettime() on Android projects, but I haven’t been able to find the right library to link to for this. Can anyone tell me what I need to link to for the ARM to make this work?

Or make any other suggestions as to alternatives that will work on the Android.

I am very much interested in leveraging my existing makefiles from my Desktop linux projects to what extent I can, but reconfiguring them to work with the cross-compile tool chain if possible, so any suggestions which would allow for that would be very greatly appreciated.

  • 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-08T22:48:42+00:00Added an answer on June 8, 2026 at 10:48 pm

    Android’s “bionic” C library has a wrapper for the clock_gettime() syscall. If you build using the Android NDK you’ll get that automatically. Otherwise you need to add a bionic library to your toolchain somehow.

    Alternatively, you could call the syscall directly via assembly (from memory, the first argument goes in R0, the second in R1, you put the syscall number in R7, issue “SWI $0” and find the result code in R0).

    Alternatively: why are you bothering with clock_gettime? Is there any reason you can’t simply use gettimeofday()?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently developed a project which is written using Symfony 1.4 which I
I've recently started work on a new project using EpiServer which I am totally
i have recently developed a list program in android in which there is an
I recently became involved with a new software project which uses SQL Server 2000
I recently joined a new c# project in which a console application is being
I'm using a3rd party component in my project and I recently upgraded to their
I've developed a tool which I use to build other solution files, and if
hi I am a php developer. Recently I got an old project using php5
I recently developed an interop user control in .NET (Visual Studio 2008, project targetting
I have recently started working on some open source project which I found relevant

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.