Sorry for late reply. If you still interesting, the library was loaded from postgresql for so called "c style functions" (in my case they are actually written in pascal). After workaround mentioned in fpc bug report, there is no problems and library that uses imaging works very well on freebsd production server. Postgresql is written in c, but that doesn't matter because this bug would appear in any software while loading library with dlopen on bsd systems. Bug exists for several years and I don't think it will be resolved in the near future.