Linking error for libgmic

Hello @pennyloafers!

Thank you so much for your help, your tipps brought me on the right track!

I was able to get it to build with your changes to the SCsub file, unfortunatelly I only got it to work with MinGW yet. Since this would affect other parts of the project I’m not free to just substitute the build toolchain.

The library is found, and the link command generated by scons seems fine, but the linking aborts with the following error:

modules\gmic\lib\libgomp-1.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x340

I’m investigating that error right now, but was hoping that the error message might be familiar and you might have an idea about what’s going wrong.

Below is my current SCsub file for the module. I had to add “gdi32” to the linked libraries and specify the path to libgomp-1.dll directly with File(), otherwise the build aborted because it was not found. I also had to rename the libgmic.a file to gmic.windows.editor.dev.x86_64.lib because building with MSVC expects a different naming convention.

Import('env')
Import("env_modules")

gd_gmic = env.Clone()
gd_gmic.add_source_files(env.modules_sources, "*.cpp")
gd_gmic.Append(CPPPATH=['include'])

env.Append(LIBPATH=['E:/godot-source/modules/gmic/lib'])
env.Append(LIBS=[
    'gmic',
    File('lib/libgomp-1.dll'), 
    'gdi32',
    File('lib/libjpeg-8.dll'),
    File('lib/libfftw3-3.dll'),
    File('lib/libfftw3_threads-3.dll'),
    File('lib/libtiff-6.dll'),
    File('lib/libcurl-4.dll'),
])

This is the output for the linking step of the Godot build:

scons: Building targets ...
[  0%]   findlibs: looking for 'gmic.windows.editor.dev.x86_64.lib' in 'modules\gmic\lib' ...
  findlibs: ... FOUND 'gmic.windows.editor.dev.x86_64.lib' in 'modules\gmic\lib'
  findlibs: looking for 'gmic.lib' in 'modules\gmic\lib' ...
  findlibs: ... FOUND 'gmic.lib' in 'modules\gmic\lib'
  findlibs: looking for 'gdi32.windows.editor.dev.x86_64.lib' in 'modules\gmic\lib' ...
  findlibs: looking for 'gdi32.lib' in 'modules\gmic\lib' ...
[ 22%] lib /nologo /OUT:modules\module_gmic.windows.editor.dev.x86_64.lib modules\gmic\godot_gmic.windows.editor.dev.x86_64.obj modules\gmic\register_types.windows.editor.dev.x86_64.obj
[ 99%] progress_finish(["progress_finish"], [])
[100%] Using tempfile C:\Users\Patrick\AppData\Local\Temp\tmpcafge28x.lnk for command line:
link /nologo /SUBSYSTEM:WINDOWS /INCREMENTAL:NO winmm.lib dsound.lib kernel32.lib ole32.lib oleaut32.lib sapi.lib user32.lib gdi32.lib IPHLPAPI.lib Shlwapi.lib wsock32.lib Ws2_32.lib shell32.lib advapi32.lib dinput8.lib dxguid.lib imm32.lib bcrypt.lib Crypt32.lib Avrt.lib dwmapi.lib dwrite.lib wbemuuid.lib psapi.lib dbghelp.lib opengl32.lib /NATVIS:platform\windows\godot.natvis /STACK:8388608 /DEBUG:FULL psapi.lib /OUT:bin\godot.windows.editor.dev.x86_64.exe /LIBPATH:modules\gmic\lib main\main.windows.editor.dev.x86_64.lib modules\modules.windows.editor.dev.x86_64.lib modules\module_msdfgen.windows.editor.dev.x86_64.lib modules\module_theora.windows.editor.dev.x86_64.lib modules\module_vorbis.windows.editor.dev.x86_64.lib modules\module_astcenc.windows.editor.dev.x86_64.lib modules\module_basis_universal.windows.editor.dev.x86_64.lib modules\module_bmp.windows.editor.dev.x86_64.lib modules\module_camera.windows.editor.dev.x86_64.lib modules\module_csg.windows.editor.dev.x86_64.lib modules\module_cvtt.windows.editor.dev.x86_64.lib modules\module_dds.windows.editor.dev.x86_64.lib modules\module_denoise.windows.editor.dev.x86_64.lib modules\module_enet.windows.editor.dev.x86_64.lib modules\module_etcpak.windows.editor.dev.x86_64.lib modules\module_freetype.windows.editor.dev.x86_64.lib modules\module_gdscript.windows.editor.dev.x86_64.lib modules\module_glslang.windows.editor.dev.x86_64.lib modules\module_gltf.windows.editor.dev.x86_64.lib modules\module_gmic.windows.editor.dev.x86_64.lib modules\module_gridmap.windows.editor.dev.x86_64.lib modules\module_hdr.windows.editor.dev.x86_64.lib modules\module_jpg.windows.editor.dev.x86_64.lib modules\module_jsonrpc.windows.editor.dev.x86_64.lib modules\module_lightmapper_rd.windows.editor.dev.x86_64.lib modules\module_mbedtls.windows.editor.dev.x86_64.lib modules\module_meshoptimizer.windows.editor.dev.x86_64.lib modules\module_minimp3.windows.editor.dev.x86_64.lib modules\module_mobile_vr.windows.editor.dev.x86_64.lib modules\module_multiplayer.windows.editor.dev.x86_64.lib modules\module_navigation.windows.editor.dev.x86_64.lib modules\module_noise.windows.editor.dev.x86_64.lib modules\module_ogg.windows.editor.dev.x86_64.lib modules\module_openxr.windows.editor.dev.x86_64.lib modules\module_raycast.windows.editor.dev.x86_64.lib modules\module_regex.windows.editor.dev.x86_64.lib modules\module_squish.windows.editor.dev.x86_64.lib modules\module_summator.windows.editor.dev.x86_64.lib modules\module_svg.windows.editor.dev.x86_64.lib modules\module_text_server_adv.windows.editor.dev.x86_64.lib modules\module_tga.windows.editor.dev.x86_64.lib modules\module_tinyexr.windows.editor.dev.x86_64.lib modules\module_upnp.windows.editor.dev.x86_64.lib modules\module_vhacd.windows.editor.dev.x86_64.lib modules\module_webp.windows.editor.dev.x86_64.lib modules\module_webrtc.windows.editor.dev.x86_64.lib modules\module_websocket.windows.editor.dev.x86_64.lib modules\module_webxr.windows.editor.dev.x86_64.lib modules\module_xatlas_unwrap.windows.editor.dev.x86_64.lib modules\module_zip.windows.editor.dev.x86_64.lib platform\platform.windows.editor.dev.x86_64.lib drivers\drivers.windows.editor.dev.x86_64.lib editor\editor.windows.editor.dev.x86_64.lib scene\scene.windows.editor.dev.x86_64.lib servers\servers.windows.editor.dev.x86_64.lib core\core.windows.editor.dev.x86_64.lib modules\text_server_adv\harfbuzz_builtin.windows.editor.dev.x86_64.lib modules\text_server_adv\graphite_builtin.windows.editor.dev.x86_64.lib modules\text_server_adv\icu_builtin.windows.editor.dev.x86_64.lib modules\freetype\freetype_builtin.windows.editor.dev.x86_64.lib modules\msdfgen\msdfgen_builtin.windows.editor.dev.x86_64.lib gmic.windows.editor.dev.x86_64.lib modules\gmic\lib\libgomp-1.dll gdi32.windows.editor.dev.x86_64.lib modules\gmic\lib\libjpeg-8.dll modules\gmic\lib\libfftw3-3.dll modules\gmic\lib\libfftw3_threads-3.dll modules\gmic\lib\libtiff-6.dll modules\gmic\lib\libcurl-4.dll platform\windows\godot_windows.windows.editor.dev.x86_64.obj platform\windows\crash_handler_windows.windows.editor.dev.x86_64.obj platform\windows\os_windows.windows.editor.dev.x86_64.obj platform\windows\display_server_windows.windows.editor.dev.x86_64.obj platform\windows\key_mapping_windows.windows.editor.dev.x86_64.obj platform\windows\joypad_windows.windows.editor.dev.x86_64.obj platform\windows\tts_windows.windows.editor.dev.x86_64.obj platform\windows\windows_terminal_logger.windows.editor.dev.x86_64.obj platform\windows\vulkan_context_win.windows.editor.dev.x86_64.obj platform\windows\gl_manager_windows.windows.editor.dev.x86_64.obj platform\windows\godot_res.windows.editor.dev.x86_64.obj
link @C:\Users\Patrick\AppData\Local\Temp\tmpcafge28x.lnk
modules\gmic\lib\libgomp-1.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x340
scons: *** [bin\godot.windows.editor.dev.x86_64.exe] Error 1107
scons: building terminated because of errors.
[Time elapsed: 00:00:13.790]

The gmic library is found, and the DLL files are listed in the linking command, but the libgomp-1.dll file cannot be used to link agains.

I appreciate your help so far and thank you in advance for any thoughts on how to get this to build with MSVC.

Thanks and best regards,
Patrick