Skip to content
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

Fix MSVC 2022 Compilation #535

Merged
merged 1 commit into from
Sep 1, 2023
Merged

Fix MSVC 2022 Compilation #535

merged 1 commit into from
Sep 1, 2023

Conversation

cfis
Copy link
Contributor

@cfis cfis commented May 21, 2023

This PR fixes compiling the pg extension with MSVC 2022 when using extconf.rb, nmake and libpq installed by vcpkg (not mingw64).

Running the command:

ruby extconf.rb --without-pg-config --with-pg-include=c:\Source\vcpkg\installed\x64-windows\include --with-pg-lib=c:\Source\vcpkg\installed\x64-windows\lib

Fails with linker errors:

pg_connection.obj : error LNK2019: unresolved external symbol __imp_WSAGetLastError referenced in function pg_rb_thread_io_wait

This is fixed by adding ws2_32.lib to the linker command.

Not sure I am adding the extra library in the best place (or the correct way), but this does fix the issue for me.

…tconf.rb, nmake and libpq installed by vcpkg (not mingw64).

Running the command:

ruby extconf.rb --with-pg-include=c:\Source\vcpkg\installed\x64-windows\include --with-pg-lib=c:\Source\vcpkg\installed\x64-windows\lib

Fails with linker errors:

pg_connection.obj : error LNK2019: unresolved external symbol __imp_WSAGetLastError referenced in function pg_rb_thread_io_wait

This is fixed by adding ws2_32.lib to the linker command.
@larskanis larskanis merged commit a4ed045 into ged:master Sep 1, 2023
@larskanis
Copy link
Collaborator

Thank you very much! This is merged as part of #544 and will be released in pg-1.5.4 soon. I added MSVC to the CI to avoid breaking it again.

@cfis
Copy link
Contributor Author

cfis commented Sep 3, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants