4coder » Forums » MinGW dll
iamwhosiam
Anthony Romano
3 posts

i am a man.

#12313 MinGW dll
3 months, 3 weeks ago Edited by Anthony Romano on June 30, 2017, 6:42 a.m.

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
Mr4thDimention
Allen Webster
267 posts
2 projects

Heyo

#12314 MinGW dll
3 months, 3 weeks ago

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.
iamwhosiam
Anthony Romano
3 posts

i am a man.

#12319 MinGW dll
3 months, 3 weeks ago

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 :)
mmozeiko
Mārtiņš Možeiko
1485 posts
1 project
#12320 MinGW dll
3 months, 3 weeks ago Edited by Mārtiņš Možeiko on June 30, 2017, 11:49 p.m.

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 :)

iamwhosiam
Anthony Romano
3 posts

i am a man.

#12322 MinGW dll
3 months, 3 weeks ago

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 :)
mmozeiko
Mārtiņš Možeiko
1485 posts
1 project
#12323 MinGW dll
3 months, 3 weeks ago Edited by Mārtiņš Možeiko on July 1, 2017, 5:01 a.m.

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.
Mr4thDimention
Allen Webster
267 posts
2 projects

Heyo

#12327 MinGW dll
3 months, 3 weeks ago

Thanks for the tip on the error code Mārtiņš.