4coder»Forums
Anthony Romano
5 posts
i am a man.
MinGW dll
Edited by Anthony Romano on
I'm trying to build the 4coder custom dll with the mingw's gcc and im wondering am I doing something wrong and or is it even possible?

I have it building with no errors, but when I run 4coder it just tells me the dll is missing.

This is my build script.

1
2
g++ -c 4coder_default_bindings.cpp -Wno-write-strings
g++ -shared -o custom_4coder.dll 4coder_default_bindings.o -Wl,--out-implib,4coder_default_bindings.a 


EDIT: i forgot to say, im on the current version 4.0.21 of 4coder super
Allen Webster
476 posts / 6 projects
Heyo
MinGW dll
Well hopefully someone who knows MinGW better than I will come along to help, because I don't know about building a dll with g++, but I will point out that there are two reasons that error might occur. The first is if there is no dll file for it to load, the second is if it does find a dll to load, but that dll does not export one or both of these symbols: "get_alpha_4coder_version", "get_bindings".

Again, since I don't know about MinGW and building dlls with g++ that may not be the problem, just a possibly helpful piece of information.
Anthony Romano
5 posts
i am a man.
MinGW dll
I definitely have a dll file there to load, I just can't for the life of me figure out how to export the symbols correctly. Ill prolly have to bite the bullet and install visual studio...

Thank you for the information though :)
Mārtiņš Možeiko
2559 posts / 2 projects
MinGW dll
Edited by Mārtiņš Možeiko on
MinGW supports same thing as MSVC for exporting symbols - put __declspec(dllexport) before function declaration. And extern "C" too if you need to disable C++ name mangling.

Or if you don't want to use __declspec, then you'll need to use .def files.
Create whatever.def file with following content:
1
2
3
EXPORTS
  get_alpha_4coder_version
  get_bindings

And pass it to the linker arguments just like regular .o object files.

Here are more docs about both of these methods: https://sourceware.org/binutils/docs/ld/WIN32.html (rtfm :)

Anthony Romano
5 posts
i am a man.
MinGW dll
Thank you very much for the information I just got it working, it's rather embarrassing but I grabbed the 64 bit version of 4coder and forgot I was using the 32bit version of mingw.

I really wish windows would recognize that and not just fail silently, oh well, everything works perfectly now!

Again thank you :)
Mārtiņš Možeiko
2559 posts / 2 projects
MinGW dll
Edited by Mārtiņš Možeiko on
Windows recognizes that and doesn't fail silently. It sets appropriate error code (ERROR_BAD_EXE_FORMAT) when LoadLibrary function fails when loading dll in incorrect 32/64-bit process. Its up to 4coder to retrieve error code and display proper error message.
Allen Webster
476 posts / 6 projects
Heyo
MinGW dll
Thanks for the tip on the error code Mārtiņš.