LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   got an error when linking mysql with c++ using cmake in ubunto 12.04 (https://www.linuxquestions.org/questions/programming-9/got-an-error-when-linking-mysql-with-c-using-cmake-in-ubunto-12-04-a-4175466348/)

ninianne 06-17-2013 09:16 AM

got an error when linking mysql with c++ using cmake in ubunto 12.04
 
hello everyone!

now I doing my project in ubunto.

I`m developing some program using mysql, opencv.

To compile opencv in ubunto, I use cmake and it work.

but when i try to compile *.cpp file which include the code to connect to mysql server(this cpp file include <mysql/mysql.h>)

I installed libmysqlclient15-dev and mysql-server using apt-get.
And write CMakeList.txt like below

CMakeList.txt
-----------------------------------------------
cmake_minimum)required(VERSION 2.8)
project( mysqltest c cxx)
include_directories(include)
set(CMAKE_LIBRARY_PATH /lib)
set(LIBS ${LIBS} mysql)
add(executable(mysql_test mysql_test.cpp)
target_link_libraries(mysql_test ${LIBS})
------------------------------------------------

when i put "cmake ."command, it works.
but when i put "make" command it return

/usr/bin/ld : cannot find -lmysql

this error

honestly i`m not familiar with camke compiler so i don`t know how to fix this error

if anyone know how to fix this error plz let me know(plz explain how i write CMakeList.txt file to fix this error in detail cause i`m not farmiliar with cmake........)

as i told before i install

libmysqlclient15-dev and mysql-server

so i don`t know why cmake complier return it cannot find
-lmysql

thanks for your help in advance

onebuck 06-17-2013 05:27 PM

Moderator Response
 
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.


All times are GMT -5. The time now is 06:48 PM.