지난 7 일 동안 mysql을 vC++에 연결하려고합니다. 하지만 아무도 내가 여기에 필요한 것을 대답 해 줄 사람이 없다.vC++로 mysql을 연결하기
mysql에서 간단한 연결을 만들고 싶습니다. 필요한 것이 무엇인지 말해주십시오. 제 감각에서 Visual C++ Developer tool을 다운로드했습니다. mysql은 데이터베이스와 테이블을 전달하기 위해 제공됩니다. 마지막으로 C++ 용 mysql 커넥터. 내가 실행 한 모든 간단한 코드도 수행했습니다. 나는 거의이 http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-apps-windows-visual-studio.html
에 의해 irrirated하고 때문에하지 주어진 제대로 내가 포함 MySQL의 주를 추가하고 모두 같은 파일을 가지고 있기 때문에 디렉토리 나 또는 mysqlconnector 디렉토리를 선택해야한다.
내 코드 내 오류 내가해야 할 다른 무엇
error LNK2019: unresolved external symbol _get_driver_instance referenced in function _wmain
// MYSqlTesting3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<winsock.h>
#include<stdio.h>
#include "mysql_driver.h"
#include "mysql_connection.h"
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
sql::PreparedStatement *pstmt;
/* 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("test");
stmt = con->createStatement();
stmt->execute("DROP TABLE IF EXISTS test");
stmt->execute("CREATE TABLE test(id INT)");
delete stmt;
// delete con;
return 0;
}
입니다. 나는 everyforum 도움을 찾고있다. 그러나 어떤 웹 사이트도 내게 어떤 결과도주지 못했다. 이 링크에 http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-apps-windows-visual-studio.html 만약 내가 다음을 위해 내 MySQL 서버 include와 lib 디렉토리를 선택했다면. 여기서 'mysqlcppconn.dll'은 올 수 없기 때문에 링크를 작성할 수 없습니다. mysql과 C++을 문제 요구 사항과 연결시키는 성공적인 예제를 보여줄 수있는 모든 웹 사이트를 검색했습니다. 이 경우에도 "sql :: Driver * driver;" Intellisense가 아무것도 표시하지 않습니다.
이 문제를 해결하는 데 도움을주십시오.
구성 라이브러리 디렉토리에 있는지 확인 시도 할 수 있습니다 "LNK1104 : 'libmysql.lib'파일을 열 수 없습니다." 이제 커넥터 디렉토리 또는 mysql 설치 디렉토리의 라이브러리를 어디에 추가해야하는지 잘 모릅니다. – user1118700
그 easy.just 어디서나 lib 파일을 넣어하지만 이렇게 : 프로젝트 -> 속성 -> 링커 -> 일반 -> 추가 라이브러리 디렉토리. 폴더를 거기에 다시 작성하십시오. – rkosegi
나는 그 오류가 올 것 "LNK1104 : libmysql.lib '파일을 열 수 없습니다. 이제 내가 어디 C/라이브러리 디렉토리를 추가해야합니다/커넥터 디렉토리 또는 mysql 설치 directory.Because 내가 설치 한 커넥터를 포함하는 경우 한 stear 때문에/C++. libmysql.lib가 아니라 'mysqlcppconn.lib'과 'mysqlcppconn.dll'만 있습니다. 그리고 내가 main mysql 서버의 libaray를 포함하고 있다면 'libmysql.lib'이 아니라 'mysqlcppconn.lib'가됩니다. 왜 libaray를 포함해야하는지 혼란 스럽습니다. – user1118700