Hi there,
Is it possible to compile shaders to windows .dll's from Linux? I've been trying through mingw, but even though the compilation succeeds, it seems the shader can't be loaded (unable to load dynamic library some_shader.dll: The specified module could not be found.)
I've been trying with x86_64-w64-mingw32-g++ .
Has anyone had any luck on this front? Is this supposed to work?
Lol you are a shading god, I loved your tutorials on flipperd normals. Shouldn't windows be used to compile dll's is using Linux really right?
@zeno pelgrims
Don't the dependencies (ai.lib) have to be cross-compiled too?
Use (http://www.dependencywalker.com/depends22_x64.zip) to check what your dll is missing that is preventing it to be seen/loaded.
@stephenblair, is this something that is possible to do from a user perspective?
@maxtarpini, thanks for that pointer - I checked with https://github.com/lucasg/Dependencies (an up to date version of dependency walker) and it does seem there's some clearly crucial missing dependencies:
- libgcc_s_seh-1.dll
- libstdc++-6.dll
- ai.dll
The quest continues!
I think Stephen is correct - I don't think it's possible after all to link MSVC libs (e.g arnold) to mingw, unless solidangle compiles arnold on their side in mingw.
@Zeno Pelgrims I think you are better off using OSL for all of your shading needs. dll's dont always are the best option.
Zeno said : "I don't think it's possible after all to link MSVC libs (e.g arnold) to mingw, unless solidangle compiles arnold on their side in mingw."
Not necessarly.
It would be like that if you call the DLL explicitly at runtime not if you use an 'import library' like ai.lib that contains additional info for the linker at compile time.
Having compiled a simple shader in fact it simply loads correctly and is available from maya UI and all of that. It even renders 🙂
Compiled with: /opt/mingw64/bin/x86_64-w64-mingw32-g++ romboMix2Shaders.cpp -I"/home/max/git/RomboArnold/romboext/_aisdk/include" -std=c++11 -fpic -O3 -c
Linked with: /opt/mingw64/bin/x86_64-w64-mingw32-g++ -shared -o romboTESTlib.dll romboMix2Shaders.o -l:ai.lib (note the colon ':' to be able to explicitely spec the lib name)
Rename rombotestlib.txt to rombotestlib.dll and check it to see it has been compiled with mingw.
However some other shader could crash at arnold runtime because of some other stuff that's assumed to be 'windows' alike and where maybe mingw is not fully compliant.. aka threading, alignments, handlers etc.
For example I just tested that if I use arnold 'closures' it badly crashes.
@Max Tarpini you legend! I'll try that out when I get home. This is super helpful man, much appreciated.
I tested this and while I'm able to load the plugin, it crashes as soon as it's executed. Was worth the try anyway.
yep also it looks like latest mingw uses gcc 4.9 which is 6 years old so all 'modern' c++ is barely supported (ie. only a subset of C++11). Btw if your problem is cross-compilation you can use cmake as your builder on linux and then use visual studio that from 2017 support cmake projects.