Code::Blocks Forums

User forums => Help => Topic started by: Durango2007 on November 19, 2008, 11:05:41 am

Title: CB cannot find mysql libs?!
Post by: Durango2007 on November 19, 2008, 11:05:41 am
Hello I am trying to compile a simple program that connects to a running mySql server database.
Problem is that the err

C:\Documents and Settings\Durango\code\C\mySqlTest.c:3: mysql.h: No such file or directory
C:\Documents and Settings\Durango\code\C\mySqlTest.c:5: error: `MYSQL' does not name a type
C:\Documents and Settings\Durango\code\C\mySqlTest.c:: In function `int main()':
C:\Documents and Settings\Durango\code\C\mySqlTest.c:10: error: `mysql' undeclared (first use this function)
C:\Documents and Settings\Durango\code\C\mySqlTest.c:10: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Documents and Settings\Durango\code\C\mySqlTest.c:10: error: `mysql_init' undeclared (first use this function)
:: === Build finished: 5 errors, 0 warnings ===

In my Global compiler settings section, in the "linker settings" tab I have added the required libraries for compiling the code.
E:\MySQL\MySQL Server 5.0\lib\opt\libmysql.lib
E:\MySQL\MySQL Server 5.0\lib\opt\mysqlclient.lib
E:\MySQL\MySQL Server 5.0\lib\opt\mysys-nt.lib

Under the "Search Directories" -> "linker" tab I have added
E:\MySQL\MySQL Server 5.0\lib\opt

Here is the code (I have minimized it to practically nothing):

#include <stdlib.h>
#include <stdio.h>
#include <mysql.h>

MYSQL mysql;

int main(void)
{

   mysql_init(&mysql);
   
   return 0;
}

Any help would be appreciated.   :D
Title: Re: CB cannot find mysql libs?!
Post by: dje on November 19, 2008, 11:14:38 am
Hi!

Under the "Search Directories" -> "linker" tab I have added
E:\MySQL\MySQL Server 5.0\lib\opt
You have to do the same for the compiler tab to put the directories where your includes are stored.

Another thing, you might have problems if you use paths with spaces depending on what tools you use.

Dje
Title: Re: CB cannot find mysql libs?!
Post by: Durango2007 on November 20, 2008, 02:05:35 am
I tried what you listed but no luck :(
If you have any other suggestion I'm all eyes.
Title: Re: CB cannot find mysql libs?!
Post by: Durango2007 on November 20, 2008, 09:50:08 am
I was able to overcome that hump, seems like just adding mysql w/o the lib prefix and .lib suffix did the trick.

I now have a new issue that hopefully is not too bad.

the linker ld.exe cannot find -lmysql.

Here is the Build log message:

mingw32-g++.exe -Wall -D__LCC__  -IE:\MinGW\include -I"E:\MySQL\MySQL Server 5.0\include"  -c "C:\Documents and Settings\Durango\code\C\mySqlTest.c" -o "C:\Documents and Settings\Durango\code\C\mySqlTest.o"
mingw32-g++.exe -LC:\MinGW\lib -L"E:\MySQL\MySQL Server 5.0\lib\opt"  -o "C:\Documents and Settings\Durango\code\C\mySqlTest.exe" "C:\Documents and Settings\Durango\code\C\mySqlTest.o"   -lmysql
E:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lmysql
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
 

Here are some screen shots of my settings

(http://img440.imageshack.us/img440/7879/compilerscrnmq9.jpg)
(http://img407.imageshack.us/img407/2828/compilerscrn2al0.jpg)
(http://img504.imageshack.us/img504/125/compilerscrn3uf9.jpg)
(http://img149.imageshack.us/img149/6677/compilerscrn4ny4.jpg)

Thank you for any help
Title: Re: CB cannot find mysql libs?!
Post by: mmkider on November 20, 2008, 10:25:01 am
check libmysql.a if exist at theE:\MySQL\MySQL Server 5.0\lib\opt.
I remember it don't exist at the  E:\MySQL\MySQL Server 5.0\lib\opt.

Title: Re: CB cannot find mysql libs?!
Post by: Durango2007 on November 21, 2008, 03:32:47 am
The only file I see in E:\MySQL\MySQL Server 5.0\lib\opt is libmysql.lib there is no libmysql.a.
Title: Re: CB cannot find mysql libs?!
Post by: MortenMacFly on November 21, 2008, 07:12:04 am
The only file I see in E:\MySQL\MySQL Server 5.0\lib\opt is libmysql.lib there is no libmysql.a.
The try to use either "libmysql.lib" in the linker options or even including the whole path to the lib, namely: E:\MySQL\MySQL Server 5.0\lib\opt\libmysql.lib (when you add the library C::B will ask you accordingly).

BUT: You are using a VC environment with MinGW/GCC. This might work but there is no guarantee. I strongly suggest you either develop with a VC compiler or download the SQL libraries (DevKit) for MinGW/GCC.