-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build failed in Windows 10 #711
Comments
Yes, this is a known problem with MinGW! Basically that header seems to have been broken for years. And I keep thinking that we managed to work around it. Could you perhaps try it with the very latest libpqxx code from a "git clone" of the repo? |
Hi ! I tried with the lastest master git-clone version from the repo, but it still gives the same error unfortunately. |
Try this... In your build tree, after running "cmake," look for the headers in #define PQXX_HAVE_SLEEP_FOR In a CMake build, three headers will have that line: |
Hi, Your workaround works ! Thanks a lot ! Just for my knowledge, what does this action imply on the Libpqxx or PostgreSQL operation ? |
My test code is very simple : just initiate a connection with a local Postgres database. But it's not working. Program run return -1. #include <iostream>
#include <pqxx/pqxx>
int main()
{
try {
pqxx::connection c{"dbname = test user = postgres password=xxx hostaddr=127.0.0.1 port=5432"};
} catch () {
std::cout << "Cannot connect to database" << std::end;
}
return 0;
} Is there a chance that the problem comes from my PostgreSQL installation ? |
Should be fine... The code to "sleep" (e.g. when you wait for notifications) may be a bit less efficient than it could be. |
Don't just |
Oh, and... you wrote std::end where you probably meant std::endl. |
We cannot predict from the source code why your machine cannot connect to the database. #include <iostream>
#include <pqxx/pqxx>
int main()
{
try {
pqxx::connection c{"dbname = test user = postgres password=xxx hostaddr=127.0.0.1 port=5432"};
-} catch () {
- std::cout << "Cannot connect to database" << std::end;
+} catch (std::exception const &ex) {
+ std::cout << "Cannot connect to database" << std::endl;
+ std::cout << "what: " << ex.what() << std::endl;
+ return 1
}
return 0;
} |
Hi guys, But you may be right, something else sould be missing with my installation. I'll check that from my side as you cannot know what is installed or not installed on my computer. That you guys for your time. |
That sounds like your code never really started at all. Because if your application tried and failed to connect, you'd be getting a 1, not a -1. So I think it's the operating system trying to tell you something like "I was unable to load a library that this application needed." |
On a sidenote, the warning "Please include winsock2.h before windows.h" bothers me as well. That warning starts in src/wait.cxx line 12, but that does not look like the right line in the current code. And the warning does not look valid: the Is that warning still there with the latest libpqxx code? |
You're right. Thank you @jtv, I'll investigate about it. You can consider the issue closed. |
My bad I didn't notice your last message. Actually no, this warning has gone when using the latest libpqxx code |
I noticed that the code runs when not using any pqxx functionality, simply including the pqxx library with : Does it mean something interesting ? |
Glad to hear that the warning is gone with the latest code! I'm eager to release 7.8.0 soon, and I would very much like the release to resolve this problem. For the strange behaviour with the failure, I think a debugger may be called for. It's important to bear in mind that with a DLL (a "shared library" in Unix parlance) the loader (the part of the OS that loads your application when you try to run it) has to be able to find that library at that time, not just when you build the application. |
@yannlr37 did you find any solution to this? My only guess so far is that the OS either couldn't find one of the DLLs it needed at runtime when you tried to run the application, or it couldn't link the DLL. I believe Windows looks for DLLs in the current directory, and in the directories specified by the PATH variable. |
Hi @jtv , l’m sorry I didn’t write, but yes you ´re right. Some DLL where missing : one related to Postgres itself (it was there but not in the PATH) and a second (libintl-9.dll) that I had to install. I did not see it in the first place because my IDE didn’t tell anything. Informations were given by a Windows dialog when app launched from console. Once these DLL installed and linked, it all worked. However, I still need to comment the lines you told me in the files generated by CMake. Thanks a lot for your help ! |
@yannlr37 I hope that 7.8.1 builds out of the box for you. |
Hi @jtv , unfortunately version 7.8.1 still gives me the |
Gah! I'm going to have to find myself a Windows system with MinGW so I can look for a reliable way to reproduce the problem. |
We've gone through a few different problems in this ticket, so to avoid confusion, I'll just close this one. If the MinGW threading problem comes up again, we can have a separate ticket for that. |
Hello,
I'm sorry if this is the wrong place for posting but I'm stuck and a help would be appreciated.
I'm new in C++ development. I'm currently working on a project using PostgreSQL database (version 15.3).
My code uses C++20.
A have a dependency to libpqxx as a static library, CMake is used to build the project.
Here is my configuration :
CMake does not detect any problem but issues come at build time :
The same code builds and runs perfectly on Linux (using GCC and CMake too).
I can't figure out where the issue comes from. Is this related to a bad configuration of the toolchain on Windows ?
Is this a known issue ?
Thanks in advance
The text was updated successfully, but these errors were encountered: