From: http://hi.baidu.com/amwdi/item/bf2d61075b25a1dd73e6760b

undefined reference to "sleep"

#include <stdio.h>
#include <unistd.h>
int main()
{
    printf("Test starts.\n");
    sleep(1);
    printf("Test ends.\n");

    return 1;
}
    

Try this at the top:

#ifdef __unix__
# include <unistd.h>
#elif defined _WIN32
# include <windows.h>
#define sleep(x) Sleep(1000 * x)
#endif


Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐