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

cmakelists文件 #64

Open
ChenXinShuo1998 opened this issue Jul 30, 2021 · 5 comments
Open

cmakelists文件 #64

ChenXinShuo1998 opened this issue Jul 30, 2021 · 5 comments

Comments

@ChenXinShuo1998
Copy link

请问有cmakelists文件吗,我根据makefile写的cmakelists但是运行后不能进入,命令行上一直显示close17 close16

@Young-Flash
Copy link

我也是遇到这个问题。自己写了 CMakeLists.txt 后可以正常编译构建,运行的时候命令行上一直显示 close18。不过能输出日志

@Young-Flash
Copy link

@ChenXinShuo1998 找到原因了。是 webserver.cpp 中root文件夹路径的问题。我猜你是新建了一个 build 文件夹构建然后运行项目,所以 root 文件夹路径就错了,可以自己输出 m_root 变量看看。我改了路径之后就好了

@mmksir
Copy link

mmksir commented Jul 26, 2022

@Young-Flash 可以把你的cmakelists发一下吗,我自己写的老是报错

@Young-Flash
Copy link

sorry 过了太久了我已经删掉了

@PoLyGaLa20
Copy link

PoLyGaLa20 commented Mar 28, 2023

webserver.cpp里WebServer::WebServer()有个getcwd(),这个函数得到的是“当前工作目录的绝对路径”。如果使用外部构建的方法(创建build文件夹在里面cmake)生成的server可执行文件在build里,如果终端的当前工作目录目录在build里,getcwd()函数获取的路径就不对了,因为这个项目的头文件inlclude都是用相对路径 " ./XX和 ../XX"引用的。

所以解决办法就是让运行web程序的终端在工作路径 ~/myWeb/TinyWebServer-master 下,再运行./build/server就行了,内部构建还是外部构建也无所谓。

写了一个cmake,添加mysql和pthread的依赖
image

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

4 participants