[fpc-pascal] x86_64 linking issue (2.1.4)

Alan Krause alank at shermanloan.com
Thu May 24 18:17:10 CEST 2007

I have successfully ported a Delphi DLL to a compiled shared library 
under 32-bit linux using free pascal, and it works wonderfully. 
Yesterday, I decided to try and port it over to the x86_64 architecture 
on linux.

For the most part, everything went smoothly - there was a small issue 
which I resolved using PtrInt instead of integer, and all units now compile.

The problem arises when the linker attempts to put all the pieces 
together into one .so :

/usr/bin/ld: uCUNASP_CLCalc.o: relocation R_X86_64_32S against 
`U_UCUNASP_CLCALC_CUNASPCLSET' can not be used when making a shared 
object; recompile with -fPIC
uCUNASP_CLCalc.o: could not read symbols: Bad value

I have successfully created a shared library, so it is not an -fPIC 
issue (I think, and am compiling with the -Cg flag as well).

The CUNASPCLSET refers to a public unit-wide variable (a custom record 
type). If I redeclare the record type as an object and dynamically 
create the variable in the unit's initialization section (and free it up 
on finalization), then the error disappears, and a similar issue pops up 
with another record type in a different unit.

Again - the code works fine on 32-bit linux, but not for x86_64. Does 
anyone have any ideas?

Thanks much,
  Alan Krause

More information about the fpc-pascal mailing list