2013-12-12 2 views
2

데이터베이스에서 일부 값을 가져 오려고 했으므로 &이 설치되었습니다. this. 필요한 헤더를 포함하고이 링커 오류가 발생했습니다.C++ MySQL 링커 오류

warning C4251: 'sql::mysql::MySQL_Connection::proxy' : class 'boost::shared_ptr<T>' needs to have dll-interface to be used by clients of class 'sql::mysql::MySQL_Connection'

#include "stdafx.h" 
#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> 

using namespace std; 

int main(void) 
{ 
    try 
    { 
     sql::Driver *driver; 
     sql::Connection *con; 
     sql::Statement *stmt; 
     sql::ResultSet *res; 

     /* Create a connection */ 
     driver = get_driver_instance(); 
     con = driver->connect("tcp://127.0.0.1:3306", "root", "root"); 
     /* Connect to the MySQL test database */ 
     con->setSchema("trinity"); 

     stmt = con->createStatement(); 
     res = stmt->executeQuery("SELECT * FROM test WHERE test='Tester'"); // replace with your statement 
     while (res->next()) 
     { 
      cout << "\t... MySQL replies: "; 
      /* Access column data by alias or column name */ 
      cout << res->getString("_message") << endl; 
      cout << "\t... MySQL says it again: "; 
      /* Access column fata by numeric offset, 1 is the first column */ 
      cout << res->getString(1) << endl; 
     } 
     delete res; 
     delete stmt; 
     delete con; 

    } 
    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; 
    } 

    cout << endl; 

    return EXIT_SUCCESS; 
} 

누군가가 발생 할 수 있습니다 알고 있나요 : (. 나는 또한 부스트를 사용하고 있습니다)

error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __thiscall sql::SQLException::getSQLState(void)const " ([email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@XZ) referenced in function __catch$_main$0 
error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall sql::SQLException::getErrorCode(void)const " ([email protected]@[email protected]@QBEHXZ) referenced in function __catch$_main$0 
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sql::SQLString::~SQLString(void)" ([email protected]@@[email protected]) referenced in function _main 
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sql::SQLString::SQLString(char const * const)" ([email protected]@@[email protected]@Z) referenced in function _main 
error LNK2019: unresolved external symbol __imp__get_driver_instance referenced in function _main 
error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __thiscall sql::SQLString::asStdString(void)const " ([email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@XZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class sql::SQLString const &)" ([email protected]@[email protected][email protected]@[email protected]@@[email protected]@[email protected]@@@Z) 
fatal error LNK1120: 6 unresolved externals 

나는이 같은 경고의 몇 가지 있어요?

답변

2

정확한 라이브러리를 추가 했습니까? Visual Studio를 실행하고 있으므로 헤더를 추가 한 것으로 보입니다. 따라서 #pragma comment(lib, <mysql lib>)을 실행하거나 링커 아래의 프로젝트 설정에서 해당 lib를 추가하십시오.

+1

이미 작동하지 않았습니다. – Blacktempel

+0

그래서 ... 모든 라이브러리를 삭제하고 MySQL 커넥터를 다시 설치했습니다. 이제 나는이 놀라운 오류에 직면 해있다. 참고로이 '.dll'파일은 라이브러리와 같은 폴더에 있습니다. '컴퓨터에 mysqlcppconn.dll이 없으므로 프로그램을 시작할 수 없습니다. 이 문제를 해결하기 위해 프로그램을 다시 설치하십시오. ' – Blacktempel

+1

DLL은 프로그램을 실행중인 폴더 또는 일부 시스템 dll 디렉토리에 있어야합니다. 만약 당신이 VS를 통해 프로그램을 실행하고 있다면, 라이브러리는 (생각합니다.) 프로젝트 디렉토리 (vcproj와 다른 파일들이있는 곳)에서 디버그/릴리즈가 아닙니다. –