Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-06

freepascal + mysql5 + osx

10 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Harald Lapp

hello,

after reading every bit of freepascal + mysql5 i could find on the net, i have still some problems getting this to run on OSX. i've installed mysql-5.0.45 and as i'm developing mainly with PHP and i compiled PHP with mysql support on my own, everything regarding mysql needed for developing with freepascal should be installed already. i've tried with the example posted on this mailinglist a while ago: http://article.gmane.org/gmane.comp.compilers.free-pascal.general/11357 however, i don't get it to work -- i get error messages from the linker:

Free Pascal Compiler version 2.2.0 [2007/08/30] for i386 Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Darwin for i386
Compiling materialize.pas
Assembling materialize
Linking materialize
ld64: warning: option -s is obsolete and being ignored Undefined symbols:
"_mysql_refresh", referenced from:
MYSQL50_MYSQL_RELOAD$PMYSQL$$LONGINT in mysql50.o
"_mysql_fetch_row", referenced from:
_PASCALMAIN in materialize.o
"_mysql_close", referenced from:
_PASCALMAIN in materialize.o
"_mysql_query", referenced from:
_PASCALMAIN in materialize.o
"_mysql_real_connect", referenced from:
_PASCALMAIN in materialize.o
"_mysql_init", referenced from:
_PASCALMAIN in materialize.o
"_mysql_select_db", referenced from:
_PASCALMAIN in materialize.o
"_mysql_store_result", referenced from:
_PASCALMAIN in materialize.o
ld: symbol(s) not found
Error: Error while linking
Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)

any ideas why freepascal complains about undefined symbols?

regards,
harald lapp

Reply by email

Jonas Maebe
to Harald Lapp
Harald Lapp wrote 10 lines
after reading every bit of freepascal + mysql5 i could find on the net, i have still some problems getting this to run on OSX. i've installed mysql-5.0.45 and as i'm developing mainly with PHP and i compiled PHP with mysql support on my own, everything regarding mysql needed for developing with freepascal should be installed already. i've tried with the example posted on this mailinglist a while ago: http://article.gmane.org/gmane.comp.compilers.free-pascal.general/ 11357 however, i don't get it to work -- i get error messages from the linker:

Add the following to your program:

{$linklib mysql50}

The reason that this is not necessary on other platforms, is that they implicitly add that based on the external declarations. This was disabled for Darwin when initially porting FPC to that platform because a lot of those external library declarations were wrong there. This was never properly resolved later on, hence the need to still explicitly add the {$linklib ...} statements for Darwin.

Jonas

Reply by email

Florian Klaempfl
to Jonas Maebe
Show quoted text 24 lines
On 22 Jun 2008, at 12:21, Harald Lapp wrote: > after reading every bit of freepascal + mysql5 i could find on the > net, i have still some problems getting this to run on OSX. i've > installed mysql-5.0.45 and as i'm developing mainly with PHP and i > compiled PHP with mysql support on my own, everything regarding mysql > needed for developing with freepascal should be installed already. > i've tried with the example posted on this mailinglist a while ago: > http://article.gmane.org/gmane.comp.compilers.free-pascal.general/11357 > however, i don't get it to work -- i get error messages from the > linker: Add the following to your program: {$linklib mysql50} The reason that this is not necessary on other platforms, is that they implicitly add that based on the external declarations. This was disabled for Darwin when initially porting FPC to that platform because a lot of those external library declarations were wrong there. This was never properly resolved later on, hence the need to still explicitly add the {$linklib ...} statements for Darwin.

It could be added to the mysql 5 unit, no?

Reply by email

Jonas Maebe
to Florian Klaempfl
Florian Klaempfl wrote 11 lines
Jonas Maebe schrieb: > Add the following to your program: > {$linklib mysql50} > The reason that this is not necessary on other platforms, is that > they implicitly add that based on the external declarations. This > was disabled for Darwin when initially porting FPC to that platform > because a lot of those external library declarations were wrong > there. This was never properly resolved later on, hence the need to > still explicitly add the {$linklib ...} statements for Darwin. It could be added to the mysql 5 unit, no?

Yes (and similar statements to several other units as well, probably).

Jonas

Reply by email

Harald Lapp
to Jonas Maebe: Add the following to your program: {$linklib mysql50} The reason that this is not…

2008/6/22 Jonas Maebe :

Show quoted text 23 lines
On 22 Jun 2008, at 12:21, Harald Lapp wrote: > after reading every bit of freepascal + mysql5 i could find on the > net, i have still some problems getting this to run on OSX. i've > installed mysql-5.0.45 and as i'm developing mainly with PHP and i > compiled PHP with mysql support on my own, everything regarding mysql > needed for developing with freepascal should be installed already. > i've tried with the example posted on this mailinglist a while ago: > http://article.gmane.org/gmane.comp.compilers.free-pascal.general/11357 > however, i don't get it to work -- i get error messages from the > linker: Add the following to your program: {$linklib mysql50} The reason that this is not necessary on other platforms, is that they implicitly add that based on the external declarations. This was disabled for Darwin when initially porting FPC to that platform because a lot of those external library declarations were wrong there. This was never properly resolved later on, hence the need to still explicitly add the {$linklib ...} statements for Darwin.

this solved my problem -- thanks very much!!

harald

Reply by email

Jonas Maebe
to Harald Lapp
Harald Lapp wrote 19 lines
2008/6/22 Jonas Maebe : > > Add the following to your program: > > {$linklib mysql50} > > The reason that this is not necessary on other platforms, is that > they > implicitly add that based on the external declarations. This was > disabled > for Darwin when initially porting FPC to that platform because a > lot of > those external library declarations were wrong there. This was never > properly resolved later on, hence the need to still explicitly add > the > {$linklib ...} statements for Darwin. this solved my problem -- thanks very much!!

It did? I've now googled a bit and it seems that mysql50 cannot be the correct name. Did you perhaps use another name in your linklib statement?

Jonas

Reply by email

Harald Lapp
to Jonas Maebe

2008/6/23 Jonas Maebe :

Show quoted text 21 lines
On 23 Jun 2008, at 08:47, Harald Lapp wrote: > 2008/6/22 Jonas Maebe : >> > >> Add the following to your program: >> >> {$linklib mysql50} >> >> The reason that this is not necessary on other platforms, is that they >> implicitly add that based on the external declarations. This was disabled >> for Darwin when initially porting FPC to that platform because a lot of >> those external library declarations were wrong there. This was never >> properly resolved later on, hence the need to still explicitly add the >> {$linklib ...} statements for Darwin. > > this solved my problem -- thanks very much!! It did? I've now googled a bit and it seems that mysql50 cannot be the correct name. Did you perhaps use another name in your linklib statement?

yes, i first tried with {$linklib mysql50}, but that did not work. than i thought, maybe
it needs the name of the clientlib, and when i tried {$linklib libmysqlclient} it
suddenly worked.

as i'm new to freepascal i'm not sure, what the linker is looking for. for example:
i tried symlinking my libmysqlclient.dylib to mysql50.dylib and that did not work.

harald

Reply by email

Joost van der Sluis
to Jonas Maebe: Yes (and similar statements to several other units as well, probably). Jonas

Op zondag 22-06-2008 om 20:41 uur [tijdzone +0200], schreef Jonas Maebe:

Show quoted text 15 lines
On 22 Jun 2008, at 20:31, Florian Klaempfl wrote: > Jonas Maebe schrieb: >> Add the following to your program: >> {$linklib mysql50} >> The reason that this is not necessary on other platforms, is that >> they implicitly add that based on the external declarations. This >> was disabled for Darwin when initially porting FPC to that platform >> because a lot of those external library declarations were wrong >> there. This was never properly resolved later on, hence the need to >> still explicitly add the {$linklib ...} statements for Darwin. > > It could be added to the mysql 5 unit, no? Yes (and similar statements to several other units as well, probably).

In the case of Firebird there are two possible names of the library, and both are tried. Can I safely add the {$linklib ...} statements for both libraries, even if one of them doesn't exist on the system?

And will the unit be compilable at all if the library is not installed on the system?

Joost.

Reply by email

Jonas Maebe
to Joost van der Sluis
Joost van der Sluis wrote 5 lines
In the case of Firebird there are two possible names of the library, and both are tried. Can I safely add the {$linklib ...} statements for both libraries, even if one of them doesn't exist on the system?

No. But you don't need {$linklib ...} statements in case you try to dynamically load libraries, only when they are linked to the program at compile time.

And will the unit be compilable at all if the library is not installed on the system?

Yes (linking happens when compiling a program or library that uses the unit, not when compiling the unit itself).

Jonas

Reply by email

Joost van der Sluis
to Jonas Maebe

Op maandag 23-06-2008 om 11:33 uur [tijdzone +0200], schreef Jonas Maebe:

Show quoted text 11 lines
On 23 Jun 2008, at 11:28, Joost van der Sluis wrote: > In the case of Firebird there are two possible names of the library, > and > both are tried. Can I safely add the {$linklib ...} statements for > both > libraries, even if one of them doesn't exist on the system? No. But you don't need {$linklib ...} statements in case you try to dynamically load libraries, only when they are linked to the program at compile time.

Ok.

I guess that:

const mysqllib='libmysqlclient.'+sharedsuffix;
{$linklib mysqllib}

doesn't work? (And I don't want it to link to 'mysqllib' ;) )

Show quoted text 5 lines
> And will the unit be compilable at all if the library is not installed > on the system? Yes (linking happens when compiling a program or library that uses the unit, not when compiling the unit itself).

I meant a program that uses such a unit. But as long as it don's apply to dynamically loaded libraries it's not a problem.

Joost.

Reply by email