Mysql-c 예제 연습중인데 빌드가 되지 않습니다
글쓴이: paser2 / 작성시간: 화, 2013/09/24 - 8:48오후
MYSQL에 접속하는 프로그램을 한번씩 만들어보고 있습니다
c#은 문제없이 잘 되었는데 c에서 막혔습니다
http://blog.naver.com/asloud/10101192728
해당 포스트 참고해서 진행했는데 빌드시에 오류가 뜹니다
오류 1 error LNK2019: _mysql_close@4 외부 기호(참조 위치: _main 함수)에서 확인하지 못했습니다. C:\Users\gjs\Documents\Visual Studio 2010\Projects\SampleMySqlC\SampleMySqlC\main.obj SampleMySqlC 오류 2 error LNK2019: _mysql_real_connect@32 외부 기호(참조 위치: _main 함수)에서 확인하지 못했습니다. C:\Users\gjs\Documents\Visual Studio 2010\Projects\SampleMySqlC\SampleMySqlC\main.obj SampleMySqlC 오류 3 error LNK2019: _mysql_init@4 외부 기호(참조 위치: _main 함수)에서 확인하지 못했습니다. C:\Users\gjs\Documents\Visual Studio 2010\Projects\SampleMySqlC\SampleMySqlC\main.obj SampleMySqlC 오류 4 error LNK1120: 3개의 확인할 수 없는 외부 참조입니다. C:\Users\gjs\Documents\Visual Studio 2010\Projects\SampleMySqlC\Debug\SampleMySqlC.exe SampleMySqlC
인터넷에서 찾은 유일한 해결법은 코드에 다음을 추가하라고 하더군요
#pragma comment (lib, "libmysql.lib")
그러나 오류는 여전합니다
아래는 전체 코드입니다
#define SOCKET int #pragma comment (lib, "libmysql.lib") #define SERVER "127.0.0.1" #define DB "test" #define ID "root" #define PASSWORD "smic1234" #include <stdio.h> #include <string.h> #include <mysql.h> #include <errno.h> void main() { char* query = "select * from test1"; MYSQL *connection; connection = mysql_init(NULL); if (!connection) { printf("Init Failed\n"); return; } connection = mysql_real_connect(connection, SERVER, ID, PASSWORD, DB, 3306, (char*)NULL, 0); if (connection) printf("connection success\n"); else printf("connection failed\n"); mysql_close(connection); }
교양 수준으로 c를 알고 있어서 뭐가 문제인지 잘 모르겠습니다.
자료를 찾아볼려고 해도 죄다 c# 아니면 리눅스용밖에 안나오네요.
Visual Studio 2010 사용중입니다
Forums:
댓글 달기