You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I build a static version of GameNetworkingSockets for Windows from source along with its dependencies (Protobuf, OpenSSL), using CMake and MinGW on Linux (cross compile). I configure CMake with -DBUILD_STATIC_LIB=ON -DBUILD_SHARED_LIB=OFF.
When using the built library, I try using the -static argument to statically link standard libraries including libwinpthread.
This causes undefined reference errors for symbols such as __imp_pthread_mutex_lock which I have tracked down to the way the preprocessor evaluates pthread.h. In pthread.h the following preprocessor code:
causes WINPTHREAD_API to evaluate to __declspec(dllimport) because DLL_EXPORT is defined, meaning that declarations such as
int WINPTHREAD_API pthread_mutex_lock(pthread_mutex_t *m);
evaluate to
int __declspec(dllimport) pthread_mutex_lock(pthread_mutex_t *m);
which creates a reference to the symbol __imp_pthread_mutex_lock. I assume that this is some sort of import function for the actual function but I don't exactly know what's going on here.
There are some indications in different versions of pthread.h (e.g. MSYS2 MinGW64) that this version is not entirely correct and that defining DLL_EXPORT should not result in __declspec(dllimport) declarations.
However, I still believe that GameNetworkingSockets should not define DLL_EXPORT when building a static library. Thus far, my only option for using GameNetworkingSockets and statically linking pthread is to insert #undef DLL_EXPORT at an appropriate location in minbase_decls.h.
Still, if there is something going on here that I don't understand, please tell me about it.
The text was updated successfully, but these errors were encountered:
I build a static version of GameNetworkingSockets for Windows from source along with its dependencies (Protobuf, OpenSSL), using CMake and MinGW on Linux (cross compile). I configure CMake with
-DBUILD_STATIC_LIB=ON -DBUILD_SHARED_LIB=OFF
.When using the built library, I try using the
-static
argument to statically link standard libraries including libwinpthread.This causes undefined reference errors for symbols such as
__imp_pthread_mutex_lock
which I have tracked down to the way the preprocessor evaluates pthread.h. In pthread.h the following preprocessor code:causes
WINPTHREAD_API
to evaluate to__declspec(dllimport)
becauseDLL_EXPORT
is defined, meaning that declarations such asevaluate to
which creates a reference to the symbol
__imp_pthread_mutex_lock
. I assume that this is some sort of import function for the actual function but I don't exactly know what's going on here.There are some indications in different versions of pthread.h (e.g. MSYS2 MinGW64) that this version is not entirely correct and that defining
DLL_EXPORT
should not result in__declspec(dllimport)
declarations.However, I still believe that GameNetworkingSockets should not define
DLL_EXPORT
when building a static library. Thus far, my only option for using GameNetworkingSockets and statically linking pthread is to insert#undef DLL_EXPORT
at an appropriate location in minbase_decls.h.Still, if there is something going on here that I don't understand, please tell me about it.
The text was updated successfully, but these errors were encountered: