Android FAQ 45: undefined reference to & amp; #39; srand & amp; #39;

Source: Internet
Author: User

Android FAQ 45: undefined reference to & #39; srand & #39;

Ndk 10b ~ 10e has no problem in compiling and using the C random number functions srand and rand,
However, when the program is running, an error similar to the following is reported:

 error: undefined reference to 'srand' error: undefined reference to 'rand'

This leaves me puzzled.
I made the following attempts:
1. Some netizens said that my ndk version is too low to use a higher version.
I changed the original 10b to 10e, but the result still failed.
2. Some netizens say they want to replace the cross compiler with a later version. I have updated the version and the result is still not correct.
3. Some netizens say they should not use 64-bit ndk. They should use 32-bit ndk. I downloaded a 32-bit 10e, but I still cannot.

When I was about to give up the crash, foreign netizens mentioned stdlib. h, as if I had seen this header file yesterday.
I tried to add this header file, compile and run it, and pass it!

This may be the adjustment of the bionic library, which is somewhat different from the original C standard library. However, since it's okay, it's worth noting!

#include shooter.h#include 
  
   #include 
   
    void bubble_sort(int *array,int n) {    int i,j,tmp;    for(i=0;i
    
     i;j--) {            if(array[j-1]>array[j]) {                tmp = array[j-1];                array[j-1]=array[j];                array[j]=tmp;            }        }    }}int A(int a) {    int n = 10;    int i;    int array[n];    srand(time(NULL));    for(i=0;i
     
    
   
  

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.