0

I'm having issues building a PostgreSQL client on Windows. Actually, it compiles fine and runs smooth on the compiler machine (the one who has compiled the application), but on different computers (that don't have the postgresql server) it gives me errors - it can't find *.dll. I fixed this by adding .dlls manually to the folder of the application (I don't think this is a good way to deal with this and it works only for 32-bits machines).

Can you tell me which libraries should I link or how can I handle this situation?

Thank you!

2
  • What files does the PostgreSQL documentation say you need? Search the web for "dll walker". Commented May 12, 2013 at 18:11
  • @ThomasMatthews I think you mean Dependency Walker (depends.exe) from dependencywalker.com Commented May 13, 2013 at 0:07

1 Answer 1

1

You're most likely using libpq.dll, the main PostgreSQL client library. You can determine which libraries it requires using Dependency Walker, but from memory it just needs the openssl DLLs that're in the same directory as it in the PostgreSQL bin dir, and maybe zlib. I don't have a handy Windows box to check with right now. libpq and its direct dependencies from the PostgreSQL bin folder should just be bundled with your application in the same directory as your application executable. They won't be used by anything except your app and won't cause conflicts with software installed elsewhere on the system.

There's one additional dependency I suspect may be biting you: You need the appropriate version of the Microsoft Visual Studio C++ Redistributable installed on the target machines. This is installed automatically by the PostgreSQL installer. If you're bundling libpq in an application your installer must run the redist installer as well. The required version depends on exactly which PostgreSQL version you're using (which you neglected to mention); it can be determined with dependency walker.

Sign up to request clarification or add additional context in comments.

4 Comments

I found this: postgresql.org/docs/9.2/interactive/install-windows-libpq.html Is this the same thing with the libpq.dll you are talking about? What about different machines (arhitectures): 32-bits / 64-bits. Should I provide different dlls?
@Dan If your app is compiled as a native 64-bit executable for 64-bit platforms then yes you must bundle the 64-bit libpq. If your app runs as a 32-bit process using SysWow64 on 64-bit windows you need the 32-bit libpq.
So if I compile my apps on a 32-bit machine, I have to provide only 32-bits DLLs.
@dan Well, if you compile a 32-bit binary you only need the 32-bit DLLs it's linked to, yeah. (You can compile 64-bit code on a 32-bit machine just not run it there, so saying "32-bit machine" isn't quite right).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.