Context:
I am trying to use mySQL in my Xcode c++ project. And I have this simple program available to connect to mysql:
int main(){
if(!mysql_real_connect(&mysql, "localhost", "root", "PassWord", "DB", 0, NULL, 0)) {
printf("connecting to Mysql error:%d from %s\n",mysql_errno(&mysql), mysql_error(&mysql));
return -1;
}else {
printf("Connected Mysql successful!\n");
}
mysql_close(&mysql);
return 0;
}
However, I was able to connect to MySQL. After I ran this CML in my terminal
export DYLD_LIBRARY_PATH=/usr/local/lib
the program doesn't work anymore with the error showing: (my code in Xcode is below:)
I got this Error in Xcode command:
I am still able to log in to mySQL in CML with mysql -u root -p
And By Showing all port variables, the port shows shows it is running on 3306
SHOW GLOBAL VARIABLES LIKE 'PORT';
So everything is still normal in Terminal.
Also I tried to unset the DYLD_LIBRARY_PATH but got no luck.
I am wondering what is the reason to cause the problem and any possible resolutions/workaround.