I'm trying to call a winelib-function from a Linux C/C++ shared-library.
The reason for it is, that I want to call some wine-dll-functions from C#.
 

I wrote a wineg++/winegcc compiled shared-library (libtest.c), which I want to call from a gcc/g++ main program (for testing).

Inside the shared library, I try to call CryptProtectData (in Crypt32.lib) and GetVersionEx (Kernel32.lib) - for a test - and just printf the results.
Inside the main application, I dlopen the shared library,
and dlsym the wrapper-function which calls CryptProtectData/GetVersionEx, 
then I try to execute that wrapper function.

But as soon as the execution hits the CryptProtectData/GetVersionEx, I get Segmentation fault (core dumped) .

Why ?
The source-code for calling the CryptProtectData/GetVersionEx function works, tested it on Windows.
Invoking a dlsym-ed function that doesn't call a wine-function works as well.
But invoking a dlsym-ed function that calls a winelib-function does NOT work (segmentation fault).
Do I need to call any undocumented wine init-code ? 
Or what is the problem ?
Can I even run libtest.dll.so inside an application that isn't run with wine / that isn't compiled with wineg++ ?
If the latter is the case, is there some hack somewhere to make it work ?
Basically all such a hack would need to do is loading some libraries, and execute some init code, or not ?

wineg++ -m64 -shared -fPIC -Wall -lrt -ldl -lpthread -lwine -lmsvcrt -lcrypt32 -lusp10 -o libtest.so libtest.c
g++ -m64 app.c -ldl -o app
./app
 
Details/Code here:
https://stackoverflow.com/questions/52093440/how-to-call-wine-dll-functions-from-c