error: 'mutex' is not a member of 'std'

Jonathan Wakely jwakely.gcc@gmail.com
Wed Nov 13 16:11:00 GMT 2013


On 13 November 2013 05:00, net_robber wrote:
>
> Makefile:
> test.out: test.cpp Makefile
>         ${CXX}  -std=c++11 -c -o $@.o lt;
>         ${CXX} -o $@ $@.o

This is  not the cause of your problem, but that is not the right way
to use make, you should have a separate target for the .o file, not
have two commands in a single rule.

>
> compile error like this
> test.cpp: In function 'int main(int, char**)':
> test.cpp:5:2: error: 'mutex' is not a member of 'std'
>   std::mutex m;
>   ^
> test.cpp:5:13: error: expected ';' before 'm'
>   std::mutex m;
>              ^
>
> it looks libstdc++ does NOT include mutex feature while building

It should be obvious from looking at the sources that std::mutex is
only defined conditionally:

#ifdef _GLIBCXX_USE_C99_STDINT_TR1
...
#ifdef _GLIBCXX_HAS_GTHREADS

You need to see why one or both of those is not defined for your toolchain.



More information about the Libstdc++ mailing list