Page 1 of 1

dev-cpp and mysql

Posted: Sun Mar 27, 2011 12:53 am
by Lunacore
I've searched the web but I didn't find an answer to the following problem:
I want to make a connection to my database (MYSQL 5.5), but don't get the first step.

Code: Select all

#include <winsock2.h>
#include <mysql.h>
using namespace std;
MYSQL      mysql;

int main()
{
    mysql_init(&mysql);
    return 0;
}
I linked the following libs from the lib directory of MYSQL:
libmysql.lib
libmysqld.lib
mysqlclient.lib
mysqlservices.lib"
and add the include path from the MYSQL-directory.

While compiling, I get the (windows-)error:
"Id.exe funktioniert nicht mehr" (eng: "Id.exe has stopped working")

After the message, the compiler shows a lot of, mostly the same, errors:
.drectve `/DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
.drectve `/DEFAULTLIB:"libcpmt" /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
[Linker error] undefined reference to `@__security_check_cookie@4'
[Linker error] undefined reference to `_imp__connect@12'
[Linker error] undefined reference to `__security_cookie'

I use Windows 7 64bit and Dev-C++ (4.9.9.2) with Mingw/GCC 3.4.2 and run Dev-C++ as admin. Does anyone have the same error or have an idea, how to fix it?

Posted: Sun Mar 27, 2011 3:30 pm
by Sylence
Switch away from DevCpp. It's outdated and buggy.
Use Visual Studio or Code::Blocks

Posted: Fri Apr 01, 2011 4:48 am
by pippy3
Sylence wrote:Switch away from DevCpp. It's outdated and buggy.
Use Visual Studio or Code::Blocks
I'd guess the .libs were built for a newer gcc, so this should fix it.

Linking is always nasty. Make sure you're not setting the libs to only debug/release. Make sure they're in the correct folder. Make sure they have the dll in the exe folder. Make sure the working directory is correct.

If it's too much hassle you'll probably find that mysql in a c++ app is not the right approach. Why not just make it connect to a server?