LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-17-2013, 10:16 AM   #1
ninianne
LQ Newbie
 
Registered: Mar 2013
Posts: 6

Rep: Reputation: Disabled
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

Last edited by ninianne; 06-17-2013 at 10:19 AM.
 
Old 06-17-2013, 06:27 PM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,441
Blog Entries: 4

Rep: Reputation: 1503Reputation: 1503Reputation: 1503Reputation: 1503Reputation: 1503Reputation: 1503Reputation: 1503Reputation: 1503Reputation: 1503Reputation: 1503Reputation: 1503
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cmake: Using find_package(Boost) when FindBoost.cmake is not in the default location damien_d Programming 3 10-27-2010 04:40 PM
[SOLVED] Cmake error ~sHyLoCk~ Slackware 10 12-07-2009 02:00 PM
Cmake, linking libraries yfaye Programming 1 04-08-2009 07:13 PM
installed ubunto twice by mistake now in boot up screen get 2 options for ubunto salpapa Linux - Newbie 8 06-28-2007 06:24 PM
MySQL server problem after linking (mysql.sock) ewijaya Linux - General 4 01-19-2004 10:46 AM


All times are GMT -5. The time now is 05:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration