Recent

Author Topic: Can't compile a Lazarus project after remade postgres3dyn.pp and dllistdyn.pp  (Read 4514 times)

groh

  • New member
  • *
  • Posts: 7
I don't about other O.S.s, but I still couldn't be able to compile and run a simple database program using Lazarus and PostgreSql yet!
The first try gave no compiling errors but the infamous message "Can not find posgreSql client. Is it installed (libpq.so)?". It is obviously installed, but it's name is not libpq.so but libpq.dylib.
I tried everything, from renaming the libpq to copying it to other directories present on the search path, but nope!

As a last try, after googling a lot I found a guy that recommended to patch postgres3dyn.pp and dllistdyn.pp, recompile and try again.
I then edited these files, correcting the ".so"issue and the "posgresql" for "PostgresSql" and remaking and installing them, but now Lazarus says:
PPU Loading /usr/local/lib/fpc/2.4.4/units/i386-darwin/postgres/pqconnection.ppu
PPU Source: pqconnection.pp not found
Recompiling pqconnection, checksum changed for postgres3dyn
registersqldb.pas(38,3) Fatal: Can't find unit pqconnection used by registersqldb

As you can imagine, I tried everything from changing the paths to include those of the missing unit to copying it to the project's directory, passing by many clean rebuilds with no success.
It seems if you correct a piece here there's another hole appearing there...
Could anyone put some light on this issue?
Thanks,
Cesar
 >:(

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 670
The problem is that if you change something in the interface of one unit, then you also have to recompile all units that "use" this first unit. The reason is that this changed interface can have ramifications for those other units (e.g., you may have removed a function that they call, or changed the value of a constant that they use).

However, you should not have to modify the code of any unit to solve the problem:
1) postgres3dyn is already be correct for Mac OS X in FPC 2.4.4
2) dllstdyn.pp is not (also not in FPC 2.6.0), but you can fix that problem without changing the unit by
a) adding that dllstdyn to the uses clause of your main program
b) in the begin .. end. block of your main program, add as first statement
Code: [Select]
  InitialiseDllist('libpq.dylib');
and as last statement
Code: [Select]
  ReleaseDllist;

Even if it later gets initialized again using a wrong library name, that won't matter because it will ignore those initialization calls (they are simply used for reference counting, so that it will unload the library only during the final call to ReleaseDllist).

groh

  • New member
  • *
  • Posts: 7
Jmaebe,

I recall that there's (yet) no install package of FPC 2.6 for MacOS; FPC 2.4.4 is the latest one, and there both postgres3dyn.pp and dllistdyn.pp aren't yet corrected.

Something strange to me is that even after manually recompiling all those units (pqconnection.pp included) the compiler still says the unit is not found.

Anyway, I'll give your recommendations a try this weekend but in order to test it accordingly I'll have to reinstall the FPC packages.

Thanks and regards!

Cesar
 8)

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 670
postgres3dyn is correct for Mac OS X in 2.4.4: http://svn.freepascal.org/svn/fpc/tags/release_2_4_4/packages/postgres/src/postgres3dyn.pp (it uses the sharedsuffix constant to determine the extension of libpq, which is defined as 'dylib' for Darwin in http://svn.freepascal.org/svn/fpc/tags/release_2_4_4/rtl/unix/dynlibs.inc ).

You can compile with the -vtu command line option to see where the compiler is looking for the units, which ones it actually uses, and why it wants to recompile them.

groh

  • New member
  • *
  • Posts: 7
Ok, you're right about postgres3dyn.pp, but you must notice that you should not use
  InitialiseDllist('libpq.dylib');
unless you change the procedure call itself in order to take parameters as by default this procedure does not expect any.
Anyway, I finally made it work but I needed to:
0) reinstall fpc.pkg and fpc-src.pkg (just to clean up the mess I made before)
1) copy both postgres3dyn.pp and dllistdyn.pp to my project's folder
2) rename them to .pas instead of .pp
3) copy both dllisttypes.inc    and postgres3types.inc to my project's folder
4) edit postgres3dyn.pas (yes Maebe, I know I didn't need to change this one, bu I wanted to make sure both looked the same) and dllistdyn.pas and removed the #IFDEF for Unix and Windows, leaving it like this:
...
{$PACKRECORDS C}
const
    pqlib = 'libpq.dylib';
{$i dllisttypes.inc}
...
5) Clean up build files and recompile
Now it runs!
Thanks for all!
Cesar
 :D

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 670
I had only looked at the source of dllistdyn in FPC 2.6.0, there InitialiseDllist() does have the parameter already. It indeed didn't have it yet in 2.4.4