Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Durango2007 on September 05, 2007, 10:05:28 am

Title: Linking to libraries in CodeBlocks
Post by: Durango2007 on September 05, 2007, 10:05:28 am
Hello I am new to CodeBlocks and I am learning as I go, please have patience with me  :)

I have decided to pick up C again and my previous development environment was Unix using gnu-c compiler.
Currently I am trying to compile a simple program that makes use of the mysql database.
I do have path to the mysql database libraries but when I include the paths in codeblocks it seems to not pick them up  :?

Suppose the library file is D:\mysql\lib\opt\mysqlclient.lib

I want to add the path D:\mysql\lib\opt\ as my included library path.

Where in CodeBlocks is this done?

I tried going to Settings->Compiler and Debugger... than I selected the Linker Settings tab and added the lib file I needed.  I also included the path to the lib file in the search directory's linker section, and still I cannot access it.
I am using the Mingw comiler that I installed.

If anyone has any idea I would appreciate it.

Thank you :D
Title: Re: Linking to libraries in CodeBlocks
Post by: eranif on September 05, 2007, 10:15:35 am
The '.lib' extension implies that you are using mysqlclient library built using MSVC. You should get library that was built against mingw compiler. Maybe C::B did found it by the linker refuses to use it. Try also posting some of the compiler (or in your case, the linker) output - this could help people to give you more accurate answers.

HTH,
Eran

Title: Re: Linking to libraries in CodeBlocks
Post by: Durango2007 on September 05, 2007, 10:30:43 am
Here is the compiler build log:

mingw32-g++.exe -Wall  -IE:\MinGW\include  -c "C:\Documents and Settings\Durango\code\C\mySqlTest.c" -o "C:\Documents and Settings\Durango\code\C\mySqlTest.o"

C:\Documents and Settings\Durango\code\C\mySqlTest.c:3:19: 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)
Process terminated with status 1 (0 minutes, 0 seconds)
5 errors, 0 warnings


It does not seem to include a link to the library in there and I don't know where I have to set this up.
Title: Re: Linking to libraries in CodeBlocks
Post by: darthdespotism on September 05, 2007, 11:14:38 am
Wo ist denn deine mysql.h?
Title: Re: Linking to libraries in CodeBlocks
Post by: Lobotomy on October 21, 2007, 08:46:02 am
I had the same problem just yesterday and solution was found at French site (http://www.siteduzero.com/tuto-3-11231-1-utiliser-l-api-mysql-dans-vos-programmes.html). From there I downloaded the archive (http://serveur1.archive-host.com/membres/up/1394874161/download/api_mysql.zip) with missing file libmysqlclient.a which should included to "link libraries" list in "Project build options" window. And it works successfully now!