I am trying to use libwebsocket to build up my WebSocket server and I need to used libmysql in my code. I have install the libmysql and able to use it but I don't know how to include it using cmake in CMakeList.txt
I have include it in my test-server.h
#include <mysql.h>
In my CMakeList.txt, I add this
INCLUDE_DIRECTORIES(/usr/include/mysql)//this is add to the begining
when I use "make" to make the file, I got the error message
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
Here is the original code of the CMakeList.txt https://github.com/warmcat/libwebsockets/blob/master/CMakeLists.txt
The CMakeList.txt is provided by libwebsocket and I try to edit it with the follow code:
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}"
Why I can not link the library? What should I do in order to use libmysql in my libwebsocket server code? I am using ubuntu 14.04 as OS.