C++ mysqlConnector undefined reference to check



  • I used Visual Studio 2019 to program c ++ to a Linux server. I would like to use the library mysqlConnector. I compensate under
    Project properties -> Configuration properties -> VC ++ directories -> Include directories
    my path belongs to the folder with the header belonging. In my case this is: /home/system/mysqlConnector/include/jdbc
    Then I have under
    Project Properties -> Configurations-Properties -> VC ++ Directories -> Library Properties
    my path belongs to the .so file. In my case this is: /home/system/mysqlConnector/lib64
    In the end I have under
    Project Properties -> Configurations-Properties -> Linker -> Settings -> Library Permissions
    heard the name of the library. In my case this is mysqlcppconn.
    To test that I look at source code:

    #include <cstdio>
    #include <stdlib.h>
    #include <iostream>
    #include <mysql_connection.h>
    #include <cppconn/driver.h>
    #include <cppconn/exception.h>
    #include <cppconn/resultset.h>
    #include <cppconn/statement.h>
    
    int main()
    {
        std::cout << "Test" << std::endl;
            try {
            sql::Driver* driver;
            sql::Connection* con;
            sql::Statement* stmt;
            //Create a connection
            driver = get_driver_instance();
            con = driver->connect("tcp://192.168.178.57:3306", "root", "test");
            ///Connect to the MySQL test database
            con->setSchema("test");
            stmt = con->createStatement();
            std::cout << "connected" << std::endl;
            sql::ResultSet*  res(stmt->executeQuery("SELECT * FROM Test.t"));
            std::cout << "getAnswer" << std::endl;
            while (res->next()) {
               std::cout << res->getString(1) << std::endl;
            }
            delete res;
            delete stmt;
            delete con;
            
        }
        catch (sql::SQLException& e) {
            std::cout << "# ERR: SQLException in " << __FILE__;
            std::cout << "(" << __FUNCTION__ << ") on line "
                << __LINE__ << std::endl;
            std::cout << "# ERR: " << e.what();
            std::cout << " (MySQL error code: " << e.getErrorCode();
            std::cout << ", SQLState: " << e.getSQLState() << " )" << std::endl;
        }
    
        std::cout << std::endl;
        while (true);
        return EXIT_SUCCESS;
    }
    

    When I compile the project now, there are error messages every time:

    /home/system/projects/mysqlTest1/obj/x64/Debug/main.o: in function `check_lib()': mysqlTest1 D:\usr\bin\ld line 1
    
    ld returned 1 exit status mysqlTest1 D:\Tamino\Freizeit\Entwicklung\visual Studio\Workspaces\Tests\mysqlTest1\mysqlTest1\collect2 line 1
    
    undefined reference to `check(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' mysqlTest1 D:\home\system\mysqlConnector\include\jdbc\cppconn\driver.h line 77
    
    /home/system/mysqlConnector/include/jdbc/cppconn/driver.h:78: undefined reference to `check(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&)' mysqlTest1 D:\usr\bin\ld line 1
    

    Here it is also clearly recognizable that the /home and /usr pathes come from Linux and D:/ comes from Windows.
    Can someone tell me what was I doing wrong?