天天看点

undefined reference to gettid

http://topic.csdn.net/u/20100816/18/36ba57a9-6c89-42be-8f93-a37647538b55.html

 因为gettid()是Linux他自己的,因此把里面实现函数拷贝出来,写到自己的程序里即可。头文件有

<sys/syscall.h>

实现代码如下:

C/C++ code
pid_t gettid()
{
     
    return
     syscall(SYS_gettid);
}


   
      

#include <linux/unistd.h>

pid_t gettid(void)

{

  return syscall(__NR_gettid);

}

#include <sys/syscall.h>

pid_t gettid(void)

{

  return syscall(SYS_gettid);

}

好像这两个都可以。

继续阅读