Thread: error: ‘futex’ was not declared in this scope

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    14

    error: ‘futex’ was not declared in this scope

    I'm trying to write a program that uses the futex system call. I'm on Ubuntu 10.04.

    The problem is that even though I include
    #include <linux/futex.h>
    the compiler complains that it can not find its declaration. When I open up this header file, I see many macros related to the futex system call, but I can't see any functions defined at all for it (not even do_futex as I've seen at this header file online).

    What should I do?
    Thanks

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Are you getting a compiler error, or a linker error? On my Ubuntu 10.10, trying to call futex() compiles (with an implicit prototype warning) but fails to link. I imagine that means there's a library that's missing, but the man pages don't mention one. You might need some of the fancier dev packages, I suppose.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    14
    This is a compiler error that I'm getting. What do you mean by fancier dev packages...? I'm googling it but apparently I'm the first one in the internet with this problem!

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Why are you trying to use a futex?

    pthread_mutex_t uses them already - including all the "fast path" code that you are responsible for writing yourself when using a futex.

    http://linux.die.net/man/7/futex
    https://bartoszmilewski.wordpress.co...lock-vs-futex/

    gg

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    14
    thanks for the responses.

    i managed to accomplished what i wanted with:
    syscall(SYS_futex, &futexVar, FUTEX_WAKE, -999, NULL, NULL, 0);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error: was not declared in this scope compilation error
    By i_r_tomash in forum C Programming
    Replies: 2
    Last Post: 05-27-2010, 07:44 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. Nested loop frustration
    By caroundw5h in forum C Programming
    Replies: 14
    Last Post: 03-15-2004, 09:45 PM