Vote count:
0
I have built MariaDB 10.0.15 from source (with the WITH_EMBEDDED_SERVER flag) and would like to test its shared library using a simple program. I'm a total beginner with CMake.
My program is the following one :
#include <my_global.h>
#include <mysql.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
MYSQL *con = mysql_init(NULL);
if (con == NULL)
{
fprintf(stderr, "%s\n", mysql_error(con));
exit(1);
}
if (mysql_real_connect(con, "localhost", "root", "root_pswd",
NULL, 0, NULL, 0) == NULL)
{
fprintf(stderr, "%s\n", mysql_error(con));
mysql_close(con);
exit(1);
}
if (mysql_query(con, "CREATE DATABASE testdb"))
{
fprintf(stderr, "%s\n", mysql_error(con));
mysql_close(con);
exit(1);
}
mysql_close(con);
exit(0);
}
I created the following CMakeLists.txt file :
cmake_minimum_required(VERSION 2.8.4)
project(mariadb_simple_test)
add_subdirectory(/usr/src/mariadb-10.0.15/libmysqld mariadb)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(mariadb_simple_test ${SOURCE_FILES})
Is this the good way of doing it ? When trying to build it, CMake complains with the following error : Unknown CMake command "ADD_CONVENIENCE_LIBRARY", which makes me think that some CMake module is probably missing, but why ?
asked 3 mins ago
Testing the MariaDB shared library using CMake
Aucun commentaire:
Enregistrer un commentaire