I want to run my program standalone. It is simple connection to MySQL using libmysql.lib and requires libmysql.dll in order to run (have it in same folder). Now my question is, how could i compile in c::b so I can use my executable on other machine and will not require .dll? I heard about static libraries but I have no idea how it works, so would be really nice if someone could explain me the process.
P.S. I use GNU CC Compiler.
#include <iostream>
#include <winsock.h>
#include <mysql.h>
using namespace std;
int main() {
MYSQL *connect;
MYSQL_RES *res_set;
MYSQL_ROW row;
connect = mysql_init(NULL);
connect = mysql_real_connect(connect, "HOST", "USER", "PASS", "Server", 3306, NULL, 0);
while( true ) {
mysql_query(connect, "SELECT * FROM Server");
res_set = mysql_store_result(connect);
while( row = mysql_fetch_row(res_set) ) {
cout << row[0] << " " << row[1] << " " << row[2] << endl;
}
Sleep(2000);
}
mysql_close(connect);
return 0;
}
Go to Project->Build Options->(Select project name). Then select the Linker settings and click on the Add button under Link Libraries, and select libmysql.lib. This should statically compile your program, AFAIK.
See the Compiling MySQL Clients on Microsoft Windows section in the MySQL reference for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With