STD error

Hello, I am getting this following error while using the random_shuffle of the std in android ADT while the same works fine in xcode

Error : “Description Resource Path Location Type ‘random_shuffle’ is not a member of ‘std’ C/C++ Problem”

Any help would be really appreciated. Thanks in advance.

Finally got the following two solutions and that resolved my error :

At First, we need to add the following STL paths in the Project~~>Properties~~>C/C*+ General->Includes :
* <path_to_NDK>/sources/cxx-stl/gnu-libstdc**/include
* <path_to_NDK>/sources/cxx-stl/gnu-libstdc*+/libs/armeabi-v7a/include
* <path_to_NDK>/platforms/android-9/arch-arm/usr/include

Secondly, we need to include the following header in the .cpp file where we are using random_shuffle function :

#include “arguments”

Hi,
I have code completetion in std, the eclipse offer to me std::random_shuffle
but i received the compilation error:
Description Resource Path Location Type
‘random_shuffle’ is not a member of ‘std’ GameLayer.cpp /RocketThrough/Classes line 330 C/C++ Problem

I’m using eclipse and ubuntu, i tryed ndk android all versions from 7 and all versions from 8 and same error…
please help…

to use in a game, RocketThrough, i implemented the function by hand.
but i dont to want to have to make this… :frowning:
see that the function std::iter_swap works fine inside the my random_shuffle…
in GameLayer.h:

    inline int rand(void) // RAND_MAX assumed to be 32767
    {
        static long int next = 1;
        next = next * 1103515245 + 12345;
        return (unsigned int)(next/65536) % 32768;
    }

    template
      inline void random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      {
        // concept requirements
        __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
            _RandomAccessIterator>)
        __glibcxx_requires_valid_range(__first, __last);

        if (__first != __last)
        for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
          std::iter_swap(__i, __first + (rand() % ((__i - __first) + 1)));
      }

Hi,
Did you tried the solution which I’ve mentioned in the thread?

Yes man, i tried, and after your solution eclipse completention give std functions but i have compilation error in some functions…

Guilherme, have you included the headers like #include “arguments” as mentioned in my second post?

Chetan, i include everything, but #include “arguments” i receive compilation error.

Like I said:
std :: string works,
std :: vector works
std :: range () does not work
std :: random_shuffle not work
I do not understand…
What version of NDK you use?

I used android-ndk-r8e when I faced the similar error…
btw did you performed the following step?:
Right click on project~~>properties~~>c/c++ general~~>code analysis~~>Use project settings and then uncheck all the avaialble options in that for showing errors.

Right click on project~~>properties~~>c/c++ general~~>code analysis~~>Use project settings and then uncheck all the avaialble options in that for showing errors.
Yes, i did. I try build directly in console, using build-native.sh and i recieved the same error… (i speak about #include “arguments”)
I m using the same NDK

Could you please upload your class file? in which you are getting error so that I can compare that with the one which I had…

The code is referring to the book project:
Cocos2d-X by Example Beginner’s Guide
Chapter 5: On the Line - Rocket Through
I did not change anything, just insert the project in eclipse and configured according to the book and added what you posted above.

Link: http://www.packtpub.com/cocos2d-x-by-example/book

Guilherme Braga wrote:

The code is referring to the book project:
Cocos2d-X by Example Beginner’s Guide
Chapter 5: On the Line - Rocket Through
I did not change anything, just insert the project in eclipse and configured according to the book and added what you posted above.
>
Link: http://www.packtpub.com/cocos2d-x-by-example/book

Iam reading Cocos2d-X by Example Beginner’s Guide and got that error, too
You can include :

#include

yea #include “algorithm” works fine, thanks man!

Thanks.

#include works

tieu nun wrote:

Guilherme Braga wrote:
> The code is referring to the book project:
> Cocos2d-X by Example Beginner’s Guide
> Chapter 5: On the Line - Rocket Through
> I did not change anything, just insert the project in eclipse and configured according to the book and added what you posted above.
>
> Link: http://www.packtpub.com/cocos2d-x-by-example/book
>
Iam reading Cocos2d-X by Example Beginner’s Guide and got that error, too
You can include :
> #include

Thanks.

#include works

tieu nun wrote:

Guilherme Braga wrote:
> The code is referring to the book project:
> Cocos2d-X by Example Beginner’s Guide
> Chapter 5: On the Line - Rocket Through
> I did not change anything, just insert the project in eclipse and configured according to the book and added what you posted above.
>
> Link: http://www.packtpub.com/cocos2d-x-by-example/book
>
Iam reading Cocos2d-X by Example Beginner’s Guide and got that error, too
You can include :
> #include