Include MySQL
#1
Hello
I will include mysql in the mcserver code. All works but at the end it comes the error:
German:
Code:
/home/daniel/Schreibtisch/MCServer/lib/mysql/mysql_driver.h:89: Nicht definierter Verweis auf `sql::mysql::get_driver_instance()'
In english maybe:
Code:
/home/daniel/Schreibtisch/MCServer/lib/mysql/mysql_driver.h:89: Not defined reference on`sql::mysql::get_driver_instance()'

Code in Root.cpp:
Code:
void cRoot::LoadMySQL(void)
{
    try {
        sql::mysql::MySQL_Driver *driver;
        sql::Connection *con;

        /* Create a connection */
        driver = sql::mysql::get_mysql_driver_instance();
        con = driver->connect("ip:3306", "server", "1234");
        /* Connect to the MySQL test database */
        con->setSchema("permissions");

    } catch (sql::SQLException &e) {
        cout << "# ERR: SQLException in " << __FILE__;
        cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
        cout << "# ERR: " << e.what();
        cout << " (MySQL error code: " << e.getErrorCode();
        cout << ", SQLState: " << e.getSQLState() << " )" << endl;
    }

}
Includes:
Code:
#include <iostream>
#include "mysql/mysql_connection.h"
#include "mysql/mysql_driver.h"

#include "mysql/cppconn/exception.h"

using namespace std;

Code in Root.h:
Code:
///Load MySQL
    void LoadMySQL(void);

And i copy boost and mysql libs to the lib folder.
And i added in boost a CMakeList:
Code:
cmake_minimum_required (VERSION 2.6)
project (boost)

include_directories ("${PROJECT_SOURCE_DIR}/../../src/")

set(BOOST_ROOT "${PROJECT_SOURCE_DIR}")
I also had added to the root CMakeList:
Code:
add_subdirectory(lib/boost/)

I hope someone have an idea how can i fix this error.

Greetings, Daniel
Reply
Thanks given by:
#2
I'm afraid I'll disappoint you. MySQL and Boost are out of question for MCServer. Both are too difficult to set up for compiling on all platforms reliably.

There is a workaround if you want to use MySQL in plugins - the LuaRocks contains MySQL bindings for Lua and MCServer works with LuaRocks quite nicely. No need to pollute the server code any more than needed.
Reply
Thanks given by:
#3
Another thing against MySQL is that it stops the download and go feature of the server - just like vanilla you can download, run, and you have a working server. If you had to set up MySQL it would remove that ease of use.
Reply
Thanks given by:
#4
Well, that could be worked around - by default the server wouldn't use MySQL for anything, only through settings it could be made to store things in a database. But really, getting those two huge mammoths to compile is pain, especially on Windows. And I'm not sure if MySQL even has any support for the Raspberry Pi and especially for Android.
Reply
Thanks given by:
#5
You can create your own MySQL interface library lolBig Grin It's not that hard, I've done it multiple times haha.
Reply
Thanks given by:
#6
(01-07-2014, 02:27 AM)xoft Wrote: I'm afraid I'll disappoint you. MySQL and Boost are out of question for MCServer. Both are too difficult to set up for compiling on all platforms reliably.

There is a workaround if you want to use MySQL in plugins - the LuaRocks contains MySQL bindings for Lua and MCServer works with LuaRocks quite nicely. No need to pollute the server code any more than needed.
(01-07-2014, 02:37 AM)bearbin Wrote: Another thing against MySQL is that it stops the download and go feature of the server - just like vanilla you can download, run, and you have a working server. If you had to set up MySQL it would remove that ease of use.
I don't want that MySQL will be add to MCServer.
I will change the Permissions System to my own with MySQL. I only need the MySQL for linux. For other plattforms i don't need the permissions system.
Reply
Thanks given by:
#7
driver = sql::mysql::get_mysql_driver_instance();
God, this is awful. They combine the worst of C with the worst of C++: lots::of::namespaces::in:cpp and really_long_underscored_names_in_c

Well, I thought you were thinking of contributing the code back to the community. If not, then by all means go ahead and try it out. Perhaps later you'll show us that it's easy and we'll have to reconsider.

As for the error you're seeing, I'd guess that it's about the library being incomplete or something wrong with it - it does complain inside the library's own header file, so it shouldn't be an issue with how you're using it.

I still think it would be easier to create a plugin that would use the LuaRocks' MySQL binding and when a player connects it would push the permissions from DB to the player. The cPlayer API just might be enough for this, if not, we could always extend it.
Reply
Thanks given by:
#8
(01-07-2014, 02:49 AM)xoft Wrote:
driver = sql::mysql::get_mysql_driver_instance();
God, this is awful. They combine the worst of C with the worst of C++: lots::of::namespaces::in:cpp and really_long_underscored_names_in_c

Well, I thought you were thinking of contributing the code back to the community. If not, then by all means go ahead and try it out. Perhaps later you'll show us that it's easy and we'll have to reconsider.

As for the error you're seeing, I'd guess that it's about the library being incomplete or something wrong with it - it does complain inside the library's own header file, so it shouldn't be an issue with how you're using it.

I still think it would be easier to create a plugin that would use the LuaRocks' MySQL binding and when a player connects it would push the permissions from DB to the player. The cPlayer API just might be enough for this, if not, we could always extend it.

Okey. Yes i now. This should be better.. and then only get_mysql_driver_instance();
Code:
using namespace sql;
using namespace mysql;
I think so but i don't know so many from c++.

Can i edit with the startup of a own plugin the groups.ini with the settings in my mysql db? Must i restart the server to load the new groups.ini or so?
cPlayer AddToGroup can make the setting of the group working.. Then i don't need to modify MCServer Source.
Reply
Thanks given by:
#9
The cGroup API is in the gray zone - it is exported, but not documented, I think half the functions even shouldn't be exported, other half functions is missing. It should be possible to add permissions to groups at runtime, but there's no way to list the groups, no way to add a group, remove a group, remove a permission etc. This area could really use some code cleanup and some documentation.

As far as I can tell, the groups.ini file is reloaded only on server restart, so if that doesn't bother you, you can go that way.
Reply
Thanks given by:
#10
(01-07-2014, 04:22 AM)xoft Wrote: The cGroup API is in the gray zone - it is exported, but not documented, I think half the functions even shouldn't be exported, other half functions is missing. It should be possible to add permissions to groups at runtime, but there's no way to list the groups, no way to add a group, remove a group, remove a permission etc. This area could really use some code cleanup and some documentation.

As far as I can tell, the groups.ini file is reloaded only on server restart, so if that doesn't bother you, you can go that way.

Is it possible to reload the groups.ini without restart the server? Is it hard to add a reload function?
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)