Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: Hirogens on July 20, 2011, 12:48:15 am

Title: CODE::BLOCK, CYGWIN and MySql [SOLVED]
Post by: Hirogens on July 20, 2011, 12:48:15 am
Hi,

How to integrate MySQL (libmysql.a or libmysqlclient.a" to "CODE::BLOCK, CYGWIN" ?

all my test don't work....

B.Regards
Hirogens
Title: Re: CODE::BLOCK, CYGWIN and MySql
Post by: ouch on July 20, 2011, 12:50:38 am
your going to have to be a bit more specific. What is your OS, C::B version and most importantly what is the actual error your getting.
Title: Re: CODE::BLOCK, CYGWIN and MySql
Post by: Hirogens on July 20, 2011, 01:11:09 am
Scuse me,

OS : Seven
C::B version 10.05
CYGWIN (no MINWG)

I have find the library and Include of mysql on http://devpaks.org/
For me MySql 5.0.5

And I have some link error,


undefined reference to `_mysql_init'
undefined reference to `_mysql_real_connect'
undefined reference to `_mysql_error'

libmysql.a is in link line

g++-4.exe --enable-libgomp -lncurses -o Serveur.exe obj/Debug/main.o obj/Debug/Console.o    -lgomp C:/cygwin/lib/libform.a C:/cygwin/lib/libmenu.a C:/cygwin/lib/libpanel.a C:/cygwin/lib/libncurses.a C:/cygwin/lib/mysql/libmysql.a -lmysql


B.Regards
Title: Re: CODE::BLOCK, CYGWIN and MySql
Post by: reckless on July 20, 2011, 02:54:52 am
not related to C::B so expect this thread to be locked.

just a warning.

and in regards to mysql it is sometimes hard to get to work with mingw/cygwin (not impossible though) my guess is that the import library is broken.

put this in a bat file

call it reimp.bat

@echo off
for %%A in ("%1") do pexports %%A > tmp.def
for %%A in ("%1") do dlltool --dllname %%A --def tmp.def --output-lib lib%%A.a

make sure you have pexports.exe from mingw now run it in a windows prompt in the directory where libmysql.dll is like this reimp libmysql.dll

now you have a libmysql.a in the same dir move it to mingw/lib and try compiling again.

ofc remove the old import library and make sure you actually link against your new one.

Title: Re: CODE::BLOCK, CYGWIN and MySql
Post by: oBFusCATed on July 20, 2011, 08:06:20 am
You get pretty much the standard answer: read the FAQ :)

This one: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
And this one: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F

hint: look in the GCC's manual, what -l and -L does...
Title: Re: CODE::BLOCK, CYGWIN and MySql
Post by: Hirogens on July 20, 2011, 02:57:44 pm
not related to C::B so expect this thread to be locked.

just a warning.

and in regards to mysql it is sometimes hard to get to work with mingw/cygwin (not impossible though) my guess is that the import library is broken.

put this in a bat file

call it reimp.bat

@echo off
for %%A in ("%1") do pexports %%A > tmp.def
for %%A in ("%1") do dlltool --dllname %%A --def tmp.def --output-lib lib%%A.a

make sure you have pexports.exe from mingw now run it in a windows prompt in the directory where libmysql.dll is like this reimp libmysql.dll

now you have a libmysql.a in the same dir move it to mingw/lib and try compiling again.

ofc remove the old import library and make sure you actually link against your new one.





Thank you very much, Work perfectly

B.Regards
Hirogens
Title: Re: CODE::BLOCK, CYGWIN and MySql
Post by: Hirogens on July 20, 2011, 03:02:38 pm
Quote
You get pretty much the standard answer: read the FAQ Smile

This one: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
And this one: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F

hint: look in the GCC's manual, what -l and -L does...

I have read that, but I don't use MinGW, only CYGWIN.
My code must be 100% compatible with linux.

And I use C::B because I don't want developp by remote on my linux server.

B.Regards.
Title: Re: CODE::BLOCK, CYGWIN and MySql [SOLVED]
Post by: oBFusCATed on July 20, 2011, 03:13:55 pm
Hm, why do you think I've said something about MinGW?
The tips I've gave you apply for all compilers out there...
Title: Re: CODE::BLOCK, CYGWIN and MySql [SOLVED]
Post by: Hirogens on July 20, 2011, 04:05:42 pm
Yes sorry,

But i'm found many help topic on C::B/MinGW but not many on C::B/Cygwin .. :cry:


I have nothing against MinGW, but not quite compatible.
and of course, your help was on all compilers

B.Regards
Hirogens
Title: Re: CODE::BLOCK, CYGWIN and MySql [SOLVED]
Post by: reckless on July 20, 2011, 04:05:57 pm
np m8 :)

its pretty general stuff so obfuscated is right to making an import library for gcc using mingw tools will work just as well for cygwin since both use gcc :)

i use it all the time to get import libraries from stuff i cannot build on mingw like apache.