tinyhttpd编译出错的解决方法
2018-01-27 14:41
519 查看
book@ubuntu:/home/demo/tinyhttpd-0.1.0$ make
gcc -W -Wall -lsocket -lpthread -o httpd httpd.c
httpd.c: In function ‘startup’:
httpd.c:437:34: warning: pointer targets in passing argument 3 of ‘getsockname’ differ in signedness [-Wpointer-sign]
/usr/include/i386-linux-gnu/sys/socket.h:119:12: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘int *’
httpd.c: In function ‘main’:
httpd.c:491:24: warning: pointer targets in passing argument 3 of ‘accept’ differ in signedness [-Wpointer-sign]
/usr/include/i386-linux-gnu/sys/socket.h:214:12: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘int *’
httpd.c:495:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * (*)(void *)’ but argument is of type ‘void (*)(int)’
httpd.c:495:2: warning: passing argument 4 of ‘pthread_create’ makes pointer from integer without a cast [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * __restrict__’ but argument is of type ‘int’
/usr/bin/ld: cannot find -lsocket
collect2: ld returned 1 exit status
make: *** [httpd] Error 1
book@ubuntu:/home/demo/tinyhttpd-0.1.0$ gcc -o httpd httpd.c -lpthread
httpd.c: In function ‘main’:
httpd.c:495:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * (*)(void *)’ but argument is of type ‘void (*)(int)’
httpd.c:495:2: warning: passing argument 4 of ‘pthread_create’ makes pointer from integer without a cast [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * __restrict__’ but argument is of type ‘int’
有上面错误知:pthread_create 传递的参数有问题。
源码修改:
1、源码495行 ,改为 if (pthread_create(&newthread , NULL, accept_request, (void*)&client_sock) != 0)
2、33行改为 void* accept_request(void *); 相应的该函数的实现也要做出修改:
void *accept_request(void *pclient)
{
int client = *(int *)pclient;
...
}
https://baike.baidu.com/item/apache/6265 http://blog.csdn.net/wenqian1991/article/details/46048987 https://www.cnblogs.com/chenyang920/p/5610052.html
gcc -W -Wall -lsocket -lpthread -o httpd httpd.c
httpd.c: In function ‘startup’:
httpd.c:437:34: warning: pointer targets in passing argument 3 of ‘getsockname’ differ in signedness [-Wpointer-sign]
/usr/include/i386-linux-gnu/sys/socket.h:119:12: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘int *’
httpd.c: In function ‘main’:
httpd.c:491:24: warning: pointer targets in passing argument 3 of ‘accept’ differ in signedness [-Wpointer-sign]
/usr/include/i386-linux-gnu/sys/socket.h:214:12: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘int *’
httpd.c:495:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * (*)(void *)’ but argument is of type ‘void (*)(int)’
httpd.c:495:2: warning: passing argument 4 of ‘pthread_create’ makes pointer from integer without a cast [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * __restrict__’ but argument is of type ‘int’
/usr/bin/ld: cannot find -lsocket
collect2: ld returned 1 exit status
make: *** [httpd] Error 1
book@ubuntu:/home/demo/tinyhttpd-0.1.0$ gcc -o httpd httpd.c -lpthread
httpd.c: In function ‘main’:
httpd.c:495:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * (*)(void *)’ but argument is of type ‘void (*)(int)’
httpd.c:495:2: warning: passing argument 4 of ‘pthread_create’ makes pointer from integer without a cast [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * __restrict__’ but argument is of type ‘int’
有上面错误知:pthread_create 传递的参数有问题。
源码修改:
1、源码495行 ,改为 if (pthread_create(&newthread , NULL, accept_request, (void*)&client_sock) != 0)
2、33行改为 void* accept_request(void *); 相应的该函数的实现也要做出修改:
void *accept_request(void *pclient)
{
int client = *(int *)pclient;
...
}
https://baike.baidu.com/item/apache/6265 http://blog.csdn.net/wenqian1991/article/details/46048987 https://www.cnblogs.com/chenyang920/p/5610052.html
相关文章推荐
- Windows Phone Toolkit 编译出错解决方法
- Android编译Libwebcore出错解决方法
- 关于编译【windows核心编程】01-ShowError 源代码出错 ,解决方法!
- Cocos2d-x 3.2编译生成Android程序出错Error running command, return code: 2的解决方法
- (他山之石)MFC学习之路(三)关于编译【windows核心编程】01-ShowError 源代码出错 ,解决方法!
- VS2008 编译错误: 生成 cmd.exe 时出错 解决方法
- Xcode8中CoreData编译出错的解决方法
- linux 内核编译配置内核make menuconfig 出错解决方法
- android studio创建项目编译出错问题的解决方法
- 部分linux编译ssl出错的解决方法
- Ubuntu12.04编译ANDROID ICS出错解决方法
- LitePal编译出错Error:Unsupport type 'dbname'解决方法
- VMWare在2.6.20内核下编译出错的解决方法
- ununtu11.04下安装opencv2.2编译(make)出错的原因解析及解决方法
- Ubuntu中编译Android JellyBean 4.2.1源码出现Switch.pm出错信息的解决方法
- LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup编译出错的解决方法
- 刚下载的Android 内核编译出错解决方法
- AndroidStudio导入LeanCloudjar包编译出错及解决方法
- 关于C和C++混合编译出错的解决方法
- FFmpeg编译出错undefined reference to `img_convert’的解决方法