Problem of multiple definition of fake_mutex

Problem of multiple definition of fake_mutex


I call the header file on my header file test.h to lock and unlock sections of code.
And in the file write.cpp, i need to lock and unlock sections of code too. so, i call the test.h file which call the fake_mutex.h.

but when compiling, i have the error of multiple definition `cilkscreen::create_fake_mutex()' as following :

...: In function `cilkscreen::create_fake_mutex()':
...: multiple definition of `cilkscreen::create_fake_mutex()'
...:/home/amina/projet/cilkplus-install/include/cilktools/fake_mutex.h:79: first defined here

How can i have one copy of fake_mutex to avoid the problem of multiple definition ?

Thank you in advance,

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Which OS are you working on?

- Barry

i'm working on ubunto 10.04

amina@amina-laptop:~/projet/cilkplus-install/examples/princeFGTest$ uname -a
Linux amina-laptop 2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:35:14 UTC 2011 i686 GNU/Linux

Best Reply

I believe that adding the "inline" attribute to the declaration in fake_mutex.h will fix your problem. Here's the modified code:

    // Factory function for fake mutex
    inline fake_mutex *CILKSCREEN_CDECL create_fake_mutex() { return new fake_mutex(); }

    // Destructor function for fake mutex - The mutex cannot be used after
    // calling this function
    inline void CILKSCREEN_CDECL destroy_fake_mutex(fake_mutex *m) { delete m; }

- Barry

It works fine

Thank you,

Thanks for the confirmation. I've updated the sources.

- Barry

Leave a Comment

Please sign in to add a comment. Not a member? Join today