Repository navigation
Copying the PostgreSQL DLL. #1177
Replies: 5 comments 12 replies
|
This is a bit out of my wheelhouse, to be honest. The CMake build lives largely thanks to contributors. I think it should be possible to build libpqxx as a shared library with the CMake build — you can with the autotools build. One small detail for Windows that could be of help: I think that OS looks for shared libraries in the places listed in the |
|
After |
|
When I print PostgreSQL_LIBRARIES it only lists the libpq.lib file. The problem I am having is finding the location of the libpq DLL. In this case I am using the Windows native installer for PostgreSQL. The MinGW case is easy to handle. |
|
For other OS I am happy to go with the package libraries. The problem is Windows which has no real convention on where to install stuff (such as PostgreSQL) and allows the user to freely override the install location. At build time the pqxx library searches for, and finds, libpq.lib. When I am building an installer for my application I want to make sure that I use the libpq.dll that exactly matches that libpq.lib. With CMake I can specify that I prefer static linking, but that then applies to all dependencies, when I actually only want libpq and libpqxx statically linked. I will see if that is possible. |
Uh oh!
There was an error while loading. Please reload this page.
As part of the pqxx build it finds the PostgreSQL library and links to it. In our case, for a Windows build, it is correctly finding the import library to link to. The problem is that when we run the application it fails to start because it cannot find the DLL.
I could add a
find_package(PostgreSQL REQUIRED)but having printed out all the CMake variables in your CMakeLists.txt, that is only finding the import library, no mention of the DLL. Also, putting that in my CMakeLists.txt, I may be paranoid but I am not certain that it will necessarily find the same package as your CMakeLists.txt finds. I also have a MinGW one and may, in future, have multiple PostgreSQL installs too.I like that pqxx is a static library, but it means that I cannot use
$<TARGET_RUNTIME_DLLS:pqxx>.It would be nice if you CMakeLists.txt somehow found the DLL file and added it as a dependency. But I guess that is up to whatever magic finds the PostgreSQL package, and it doesn't seem to be setting any suitable variable. Do you have any ideas?
All reactions