Author Topic: CODE::BLOCK, CYGWIN and MySql [SOLVED]  (Read 11650 times)

Offline Hirogens

  • Multiple posting newcomer
  • *
  • Posts: 17
CODE::BLOCK, CYGWIN and MySql [SOLVED]
« 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
« Last Edit: July 20, 2011, 03:02:56 pm by Hirogens »

Offline ouch

  • Almost regular
  • **
  • Posts: 223
Re: CODE::BLOCK, CYGWIN and MySql
« Reply #1 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.

Offline Hirogens

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: CODE::BLOCK, CYGWIN and MySql
« Reply #2 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
« Last Edit: July 29, 2011, 09:51:30 am by Hirogens »

Offline reckless

  • Regular
  • ***
  • Posts: 353
Re: CODE::BLOCK, CYGWIN and MySql
« Reply #3 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.

« Last Edit: July 20, 2011, 04:03:49 am by reckless »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Hirogens

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: CODE::BLOCK, CYGWIN and MySql
« Reply #5 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

Offline Hirogens

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: CODE::BLOCK, CYGWIN and MySql
« Reply #6 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: CODE::BLOCK, CYGWIN and MySql [SOLVED]
« Reply #7 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...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Hirogens

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: CODE::BLOCK, CYGWIN and MySql [SOLVED]
« Reply #8 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

Offline reckless

  • Regular
  • ***
  • Posts: 353
Re: CODE::BLOCK, CYGWIN and MySql [SOLVED]
« Reply #9 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.