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've found a bug with either maxgui, or generating Dll's on windows.
It seems that if you import maxgui.drivers in a dll, only Bmax can load the dll.
Loading by any other non-bmax program will give an error. (126)
I think it's related to a missing library.
I removed the file libstdc++.dll.a from the mingw dir.
This should force the compiler to really statically link the lib .
The second thing is that I had to declare a function from that lib in the dll to keep the linker from skipping it.
Extern
Function nanosleep%( req:Byte Ptr, timespec:Byte Ptr)
EndExtern
Then in the dll main function I call this func.
After getting stdc++ to import, the dll failed to work because of a missing reference to libwinpthread .
Creating a dll that imports maxgui.drivers, seems to work now with these hacks, but I don't know yet what else I may have broken by removing that lib in mingw.
The text was updated successfully, but these errors were encountered:
Kerntrick
changed the title
Dll's creating in Bmax can only be used in Bmax. (missing static lib)
Dll's created in Bmax can only be used in Bmax. (missing static lib)
May 27, 2023
Most of this description is a copy of what I posted here:
https://discord.com/channels/613699895139762176/679291789840089108/1111856194957627412
I've found a bug with either maxgui, or generating Dll's on windows.
It seems that if you
import maxgui.drivers
in a dll, only Bmax can load the dll.Loading by any other non-bmax program will give an error. (126)
I think it's related to a missing library.
Example
Here is a simple dll source in bmax. : https://gist.github.com/Kerntrick/99b1ff8762b1cd847b868733989958c9
Here is a simple C file to load the dll and catch the error. : https://gist.github.com/Kerntrick/f14af49ca175da229d1f94a4b93bbd99
I think the libstdc is not being statically linked as it should. but I'm not a C guy.
![image](https://private-user-images.githubusercontent.com/29359428/241430410-f135312f-7400-46bb-948c-f948018b65cf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NTQ2MTIsIm5iZiI6MTcyNDU1NDMxMiwicGF0aCI6Ii8yOTM1OTQyOC8yNDE0MzA0MTAtZjEzNTMxMmYtNzQwMC00NmJiLTk0OGMtZjk0ODAxOGI2NWNmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDAyNTE1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY1NWYxZjU1MTU0ZmNkMDI2MmYwYjQxZmEyNWRjMmE5MTQzNzQxNWU2ZTg5YTFjOTU4MzFlNjFjNTc0ZGM0MTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.CTdT7YfCypj-E4BuosFf32a-BiTah9b8_tx2VJX9bWA)
Doing some research, it seems that adding
-static-libstdc++
will not help, as that is not the linking operation.I've tried adding different options to maxgui.drivers, but nothing seemed to help.
I did get it working (i think) by doing 2 things.
libstdc++.dll.a
from the mingw dir.This should force the compiler to really statically link the lib .
The second thing is that I had to declare a function from that lib in the dll to keep the linker from skipping it.
Then in the dll main function I call this func.
So I import that lib directly in the dll.
Import "D:\Dev\Lang\BmaxNG\MinGW32x64\x86_64-w64-mingw32\lib\libwinpthread.a"
Here is the modifed example bmax code that I was able to make working.
https://gist.github.com/Kerntrick/2fa0e359304c8bbb1ee6e092b90b9c00
Creating a dll that imports maxgui.drivers, seems to work now with these hacks, but I don't know yet what else I may have broken by removing that lib in mingw.
The text was updated successfully, but these errors were encountered: