Author Topic: Linking to libraries in CodeBlocks  (Read 6024 times)

Offline Durango2007

  • Single posting newcomer
  • *
  • Posts: 6
Linking to libraries in CodeBlocks
« 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

Offline eranif

  • Regular
  • ***
  • Posts: 256
Re: Linking to libraries in CodeBlocks
« Reply #1 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


Offline Durango2007

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking to libraries in CodeBlocks
« Reply #2 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.

Offline darthdespotism

  • Almost regular
  • **
  • Posts: 163
    • Coder's Nemesis
Re: Linking to libraries in CodeBlocks
« Reply #3 on: September 05, 2007, 11:14:38 am »
Wo ist denn deine mysql.h?

Lobotomy

  • Guest
Re: Linking to libraries in CodeBlocks
« Reply #4 on: October 21, 2007, 08:46:02 am »
I had the same problem just yesterday and solution was found at French site. From there I downloaded the archive with missing file libmysqlclient.a which should included to "link libraries" list in "Project build options" window. And it works successfully now!