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

Is the static still not working? #225

Open
s2s-k opened this issue May 17, 2022 · 7 comments
Open

Is the static still not working? #225

s2s-k opened this issue May 17, 2022 · 7 comments

Comments

@s2s-k
Copy link

s2s-k commented May 17, 2022

As far as I understood, in 1.4.0 you fixed the installation of the static version via vcpkg... or not?

PS E:\Work\vcpkg> ./vcpkg search gamenetworkingsockets
gamenetworkingsockets    1.4.0            GameNetworkingSockets is a basic transport layer for games.
The result may be outdated. Run `git pull` to get the latest results.

If your port is not listed, please open an issue at and/or consider making a pull request:
    https://github.com/Microsoft/vcpkg/issues
PS E:\Work\vcpkg> ./vcpkg install gamenetworkingsockets:x64-windows-static
Computing installation plan...
Error: gamenetworkingsockets[core] is only supported on '!(static & windows) & !uwp & !(arm64 & windows)'

I saw this PR [gamenetworkingsockets] Enable building as a static library, and add webrtc feature, it was not included in 1.4.0? Your PR 1.4.0 still does not support the static version. Why?

@eddiejames
Copy link

You can try with this vcpkg patch (also includes some physx stuff i'm working on): eddiejames/vcpkg@4202900

My original PR wasn't accepted because of webrtc stuff... I'll try and resubmit my change sometime

@s2s-k
Copy link
Author

s2s-k commented Jul 25, 2022

You can try with this vcpkg patch

I applied this patch, GNS compiled statically, but my project compiles with errors of unresolved external symbols.

error LNK2019: unresolved external symbol __imp_GameNetworkingSockets_Init referenced in function main

I have enabled the use of static vcpkg libraries in the project properties. I don't know why vcpkg didn't include the library in my project. Can this be done manually?

@s2s-k
Copy link
Author

s2s-k commented Jul 25, 2022

Okay, I solved this problem with a macro.

#define STEAMNETWORKINGSOCKETS_STATIC_LINK

But now there are the same errors in libcrypto.lib.

error LNK2019: unresolved external symbol __imp_DeregisterEventSource referenced in function OPENSSL_showfatal
error LNK2019: unresolved external symbol __imp_RegisterEventSourceW referenced in function OPENSSL_showfatal
error LNK2019: unresolved external symbol __imp_ReportEventW referenced in function OPENSSL_showfatal
...

If I can solve this problem too, I'll write.

@s2s-k
Copy link
Author

s2s-k commented Jul 25, 2022

I did it. Thank you for your patch. The problem I wrote about above is solved by using additional Windows API libraries.

#pragma comment(lib, "Advapi32.lib")
#pragma comment(lib, "User32.lib")
#pragma comment(lib, "Crypt32.lib")

It is also required to use the /MTd flag for Debug configuration and /MT for Release configuration.

@s2s-k
Copy link
Author

s2s-k commented Jul 25, 2022

Also a little warning, for those who will be switching to the static version. If you call GameNetworkingSocket_Init in the global object constructor, it may crash during static linking when it worked fine in the dynamic because of the different order of object initialization.

@bugproof
Copy link

bugproof commented Aug 12, 2022

Static should be a preferred way to consume GameNetworkingSockets. Dll makes it easier for reverse engineers to hack your game. It would be nice if static linking was allowed with vcpkg.

@rjayne-git
Copy link

I am also blocked on proper support for VCPKG_LIBRARY_LINKAGE static. I hope it is coming soon.

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

No branches or pull requests

4 participants