Author Topic: CB cannot find mysql libs?!  (Read 9671 times)

Offline Durango2007

  • Single posting newcomer
  • *
  • Posts: 6
CB cannot find mysql libs?!
« 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

Offline dje

  • Lives here!
  • ****
  • Posts: 682
Re: CB cannot find mysql libs?!
« Reply #1 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

Offline Durango2007

  • Single posting newcomer
  • *
  • Posts: 6
Re: CB cannot find mysql libs?!
« Reply #2 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.

Offline Durango2007

  • Single posting newcomer
  • *
  • Posts: 6
Re: CB cannot find mysql libs?!
« Reply #3 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






Thank you for any help

Offline mmkider

  • Almost regular
  • **
  • Posts: 150
Re: CB cannot find mysql libs?!
« Reply #4 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.


Offline Durango2007

  • Single posting newcomer
  • *
  • Posts: 6
Re: CB cannot find mysql libs?!
« Reply #5 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: CB cannot find mysql libs?!
« Reply #6 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ