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.
Any hints please?

Mailing lists / fpc-pascal / 2009-10
13 messages · 3 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
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.
Any hints please?
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.
Jonas
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.
Any further hints?
Thank you
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
Here is the head of the unit:
{
cMySQL.pas
cape61
Created by Paul Davidson on 2005/01/18.
Copyright (c) 2005 Corax Networks.Inc.. All rights reserved. }
unit cMySQL;
{$I Directives.inc}interface
{$linklib libmysqlclient.a}
uses
cBase,
cKey,
cStack,
mysql4;Using MySQL 41
Some linker output:
ld: warning: in /Users/pauldavidson/dev/cape96/libmysqlclient.a, file is not of required architecture
Undefined symbols:
"_mysql_get_host_info", referenced from:
_CMYSQL_TCCMYSQLMGR_$__GETHOSTINFO$$ANSISTRING in cMySQL.o "_mysql_free_result", referenced from:
_CMYSQL_TCCMYSQLMGR_$__QUERYLOCAL$ANSISTRING$$ANSISTRING in cMySQL.o
"_mysql_close", referenced from:
_CMYSQL_TCCMYSQLMGR_$__DESTROY in cMySQL.o
"_mysql_error", referenced from:
_CMYSQL_TCCMYSQLMGR_$__REALCONNECT$$BOOLEAN in cMySQL.o _CMYSQL_TCCMYSQLMGR_$__QUERYBATCH$ANSISTRING$$ANSISTRING in cMySQL.o
_CMYSQL_TCCMYSQLMGR_$__QUERYLOCAL$ANSISTRING$$ANSISTRING in cMySQL.o
"_mysql_store_result", referenced from:
_CMYSQL_TCCMYSQLMGR_$__QUERYLOCAL$ANSISTRING$$ANSISTRING in cMySQL.o
It goes on...
Do note the 'file is not of required architecture'. Ummm????
Thank you
[snip]
It goes on... Do note the 'file is not of required architecture'. Ummm????
It means that the library contains code for different architectures than the one you are compiling for (e.g., you are compiling for i386 and the library only contains PowerPC or x86_64 object files). That would indeed explain the problem.
You can run
lipo -info /Users/pauldavidson/dev/cape96/libmysqlclient.a
to see for which architectures the library contains code.
Jonas
dsl-corax:~ pauldavidson$ lipo -info /Users/pauldavidson/dev/cape96/ libmysqlclient.a
input file /Users/pauldavidson/dev/cape96/libmysqlclient.a is not a fat file
Non-fat file: /Users/pauldavidson/dev/cape96/libmysqlclient.a is architecture: x86_64
Noted that Xcode is set for 32 bit universal output. Tried setting it to 10.6 / 64 bit output but:
can't build libfpc.a for x86_64 (ppcx64 not found) mv: rename /Users/pauldavidson/dev/cape96/build/cape96.build/Debug/ fpc.build/libfpc.a to /Users/pauldavidson/dev/cape96/build/Debug/ libfpc.a: No such file or directory
Thank you
Off topic: Friend of mine :) http://wheresthefilm.com/Insects/Beetles/slides/StackBeetle02.html
That's correct, FPC 2.2.4 only support i386 and PowerPC for Mac OS X. The upcoming 2.4.0 release will also support x86_64, PowerPC/64 and ARM.
Jonas
Jonas Maebe wroteThat's correct, FPC 2.2.4 only support i386 and PowerPC for Mac OS X. The upcoming 2.4.0 release will also support x86_64, PowerPC/64 and ARM.
As far as I could see, there are no x86_64 Mac OS X snapshots. Is that correct?
Vincent
Yes. There aren't any PPC64 or (regular) ARM ones either. Both x86_64 and PPC64 will also only be useful for command line programs, because MacOSAll haven't been adapted for 64 bit yet (and a lot of its functionality is not available in 64 bit mode).
Jonas
Ok, 32 bit universal it is!
Is there any database access method that works with this mode for 10.6.1? And how?
Again, thank you
Paul Davidson wroteOk, 32 bit universal it is! Is there any database access method that works with this mode for 10.6.1? And how?
Since MySQL is not shipped with Mac OS X, you somehow installed/ obtained an x86_64 version of its client library. Install/obtain a ppc/ i386 version of the client library, and you can link 32 bit programs against it. Mac OS X 10.5/10.6 running on an x86_64-capable cpu can run i386, x86_64 and ppc binaries (the last ones under emulation, the rest natively).
Jonas
Now have proper version of MySQL on machine
Thank you all for help. Compiles and mostly runs :)