Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/yolanda/chap-5/lib/common.h:8:20: error: config.h: No such file or directory #25

Open
chazex opened this issue Apr 13, 2020 · 13 comments

Comments

@chazex
Copy link

chazex commented Apr 13, 2020

老师你好:
cmake的时候遇到了这个问题,是什么原因呢,没找到config.h的代码呢。
/yolanda/chap-5/lib/common.h:8:20: error: config.h: No such file or directory
如果我把config.h注释掉,又有如下错误:
[ 50%] Linking C executable tcpserver
/usr/bin/ld: cannot find -lyolanda
yolanda 找不到这个个库

@chazex
Copy link
Author

chazex commented Apr 13, 2020

还有另外一个错误,好像缺少一个文件 #include <aio.h>

CMakeFiles/aio01.dir/aio01.c.o: In function main': aio01.c:(.text+0x138): undefined reference to aio_write'
aio01.c:(.text+0x193): undefined reference to aio_error' aio01.c:(.text+0x1a7): undefined reference to aio_error'
aio01.c:(.text+0x1b9): undefined reference to aio_return' aio01.c:(.text+0x27e): undefined reference to aio_read'
aio01.c:(.text+0x2cd): undefined reference to aio_error' aio01.c:(.text+0x2e1): undefined reference to aio_return'
collect2: ld returned 1 exit status
make[2]: *** [bin/aio01] Error 1
make[1]: *** [chap-30/CMakeFiles/aio01.dir/all] Error 2
make: *** [all] Error 2

@BowenXiao1999
Copy link

还有另外一个错误,好像缺少一个文件 #include <aio.h>

CMakeFiles/aio01.dir/aio01.c.o: In function main': aio01.c:(.text+0x138): undefined reference to aio_write'
aio01.c:(.text+0x193): undefined reference to aio_error' aio01.c:(.text+0x1a7): undefined reference to aio_error'
aio01.c:(.text+0x1b9): undefined reference to aio_return' aio01.c:(.text+0x27e): undefined reference to aio_read'
aio01.c:(.text+0x2cd): undefined reference to aio_error' aio01.c:(.text+0x2e1): undefined reference to aio_return'
collect2: ld returned 1 exit status
make[2]: *** [bin/aio01] Error 1
make[1]: *** [chap-30/CMakeFiles/aio01.dir/all] Error 2
make: *** [all] Error 2

大哥,你的aio.h解决了吗?我也遇到同一个问题,老师可以帮忙看看吗?

@froghui
Copy link
Owner

froghui commented Apr 19, 2020

你们是什么环境?

@BowenXiao1999
Copy link

谢谢老师答复,我是Deepin 15.11 + Kernel 5.6,应该可以当Ubuntu对待。还在研究是link的library有问题,还是未安装aio.h成功。

@BowenXiao1999
Copy link

https://stackoverflow.com/questions/1217705/compiling-c-program-with-posix-aio-lib-on-linux
https://www.linuxquestions.org/questions/programming-9/asyncronous-i-o-problem-386914/
不知道是不是这个原因,编译的时候要加-lrt。我不熟Make,无法验证。不知道大多数人有没没有这个问题

@froghui
Copy link
Owner

froghui commented Apr 25, 2020

编译的时候加-lrt, 可以解决你的问题么?

@BowenXiao1999
Copy link

bowen@bowen-PC:~/code/yolanda/chap-30$ gcc -lrt ../lib aio01.c -o aio
aio01.c:14:24: fatal error: lib/common.h: 没有那个文件或目录
#include "lib/common.h"
^
compilation terminated.

尝试直接用gcc编译,但是不知道怎么一起编译lib,找不到lib/common.h. 不如老师把-lrt写在make里?然后我再试试?

@BowenXiao1999
Copy link

bowen@bowen-PC:~/code/yolanda/chap-30$ gcc -lrt ../lib aio01.c -o aio
aio01.c:14:24: fatal error: lib/common.h: 没有那个文件或目录
#include "lib/common.h"
^
compilation terminated.

尝试直接用gcc编译,但是不知道怎么一起编译lib,找不到lib/common.h. 不如老师把-lrt写在make里?然后我再试试?

gcc -lrt ../lib/* aio01.c -o aio 又报找不到config的错。
我make的时候30chapter之前的都正常,就是到30 aio的时候出问题了。

@froghui
Copy link
Owner

froghui commented May 3, 2020

aio可能比较特殊,暂时可以把它注释掉再试试

@Yang2096
Copy link

Yang2096 commented May 23, 2020

@BowenXiao1999 @chazex /chap-30/CMakeList.txt 的最后一行改为 target_link_libraries(aio01 yolanda rt)
commit afb3e48 改正了这个问题,commit b015eee 又给改回去了

@BowenXiao1999
Copy link

@BowenXiao1999 @chazex /chap-30/CMakeList.txt 的最后一行改为 target_link_libraries(aio01 yolanda rt)
commit afb3e48 改正了这个问题,commit b015eee 又给改回去了

Thanks. LGTM.

@DamperHa
Copy link

老师你好:
cmake的时候遇到了这个问题,是什么原因呢,没找到config.h的代码呢。
/yolanda/chap-5/lib/common.h:8:20: error: config.h: No such file or directory
如果我把config.h注释掉,又有如下错误:
[ 50%] Linking C executable tcpserver
/usr/bin/ld: cannot find -lyolanda
yolanda 找不到这个个库

同学,这个你是如何解决的啊?感谢

@huangzixun123
Copy link

@BowenXiao1999 @chazex /chap-30/CMakeList.txt 的最后一行改为 target_link_libraries(aio01 yolanda rt)
commit afb3e48 改正了这个问题,commit b015eee 又给改回去了

Thanks. LGTM.

请问将CMakeList.txt 的最后一行改为 target_link_libraries(aio01 yolanda rt)后make时候成功了,但是运行时发现没有lib/common.h文件,这个问题应该如何解决的?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants