我正在尝试使用 libwebsocket 来构建我的 WebSocket 服务器,我需要在我的代码中使用 libmysql。我已经安装了 libmysql 并且能够使用它,但我不知道如何在 CMakeList.txt 中使用 cmake 将它包含在内
我已将其包含在我的 test-server.h 中
#include <mysql.h>
在我的 CMakeList.txt 中,我添加了这个
INCLUDE_DIRECTORIES(/usr/include/mysql)//this is add to the begining
当我使用“make”来制作文件时,我收到了错误消息
CMakeFiles/test-server.dir/test-server/test-server.c.o: in function main:
test-server.c:(.text.startup+0x41): undefined reference to `mysql_init'
collect2: error: ld returned 1 exit status
这是 CMakeList.txt 的原始代码 https://github.com/warmcat/libwebsockets/blob/master/CMakeLists.txt
CMakeList.txt 由 libwebsocket 提供,我尝试使用以下代码对其进行编辑:
INCLUDE_DIRECTORIES(/usr/include/mysql)
Name: libwebsockets
Description: Websockets server and client library
Version: ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACK AGE_VERSION_PATCH}
Libs: -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -ldl -L\${libdir} -lwebsockets
Cflags: -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG -I\${includedir}"
为什么我不能链接图书馆?为了在我的 libwebsocket 服务器代码中使用 libmysql,我应该怎么做?我正在使用 ubuntu 14.04 作为操作系统。