[fpc-pascal] MySQL

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Oct 15 16:27:19 CEST 2009


On 15 Oct 2009, at 16:03, Paul Davidson wrote:

> On 2009-10-15, at 7:13 AM, Jonas Maebe wrote:
>
>> On 14 Oct 2009, at 18:14, Paul Davidson wrote:
>>
>>> FPC 2.2.4
>>> OS X 10.6.1
>>> Xcode 3.2
>>>
>>> All references to MySQL function are unresolved by linker.    
>>> libMySQLclient.a is copied to .pas directory.  Using FPC test code  
>>> for MySQL as template.
>>
>> When you use Xcode, you have to use the Xcode way to link with  
>> libraries: add the library to your project, then add the library to  
>> the "Link binary with Libraries" phase of your application target.
>>
> Added libmysqlclient.a to the project and it gets automatically  
> included in Tagets/cape96/Link Binary With Libraries.  Again same  
> linker errors: Symbols not found.  Also tried libmysqlclient.la.   
> Same result.
>
> When looking at examples and tests in FPC for MySQL they do not  
> contain any references to this library.

When you compile outside Xcode, any {$linklib xxx} statements in the  
(mysql or other) units you use will automatically cause the compiler  
to tell the linker to link with the specified libraries. So if those  
units already include {$linklib mysqlclient}, it's not required to  
explicitly also tell the program to link against it. This changes if  
you move to Xcode, because Xcode itself does all the linking and there  
is no way (that I know of) for the compiler to tell it "please also  
link against these libraries in addition to those specified in the  
project".

But you are leaving out important information, such as which mysql  
unit you are using exactly and which version the libmysqlclient.a  
comes from. Most examples use the dynamic versions of the mysql units,  
which means that the mysqlclient library is dynamically loaded at run  
time rather than statically linked (in which case no linklib statement  
or other linker instructions are required). Please also mention some  
example symbols that are reported as being missing, and post the  
linker step of the Xcode build transcript (select the error on the  
build transcript and right-click on to see the full tool invocation/ 
output).


Jonas



More information about the fpc-pascal mailing list