关于centos6.5的代码编译问题
alisx opened this issue · comments
您好,我在实践书中示例时,总提示未定义一些方法,如 undefined reference to `Open'
我下载了csapp.h,放在与示例代码相同的目录下,还是不行,想请教下您,是如何做实践的
先要把 csapp.c 编译成共享库,然后在编译具体 x.c 时引入。比如:
➜ CSAPP git:(master) ✗ gcc -shared -fPIC -I../include -o csapp.so common/csapp.c
➜ CSAPP git:(master) ✗ gcc chapter10/cpstdin.c -I../include ./csapp.so -lpthread -o cpstdin
➜ CSAPP git:(master) ✗ ./cpstdin
hello
hello
^C
谢谢回复,大体能看懂了,不太明白第5行
➜ CSAPP git:(master) ✗ ./bin/kafka-server-start.sh ./config/server.properties
的意思,是需要启动一个kafka服务吗?和对cpstdin.c的编译有什么关系?
不好意思,贴错了 ,那个不需要的。
➜ CSAPP git:(master) ✗ gcc -shared -fPIC -I../include -o csapp.so common/csapp.c
➜ CSAPP git:(master) ✗ gcc chapter10/cpstdin.c -I../include ./csapp.so -lpthread -o cpstdin
➜ CSAPP git:(master) ✗ ./cpstdin
hello
hello