Compiling shaders using mingw

Compiling shaders using mingw

zenop
Advocate Advocate
2,057 Views
11 Replies
Message 1 of 12

Compiling shaders using mingw

zenop
Advocate
Advocate

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?

0 Likes
2,058 Views
11 Replies
Replies (11)
Message 2 of 12

hitecom8172
Enthusiast
Enthusiast

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

0 Likes
Message 3 of 12

Stephen.Blair
Community Manager
Community Manager

Don't the dependencies (ai.lib) have to be cross-compiled too?



// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 4 of 12

maxtarpini
Collaborator
Collaborator

Use (http://www.dependencywalker.com/depends22_x64.zip) to check what your dll is missing that is preventing it to be seen/loaded.

0 Likes
Message 5 of 12

zenop
Advocate
Advocate

@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!

0 Likes
Message 6 of 12

zenop
Advocate
Advocate

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.

0 Likes
Message 7 of 12

hitecom8172
Enthusiast
Enthusiast

@Zeno Pelgrims I think you are better off using OSL for all of your shading needs. dll's dont always are the best option.

0 Likes
Message 8 of 12

maxtarpini
Collaborator
Collaborator

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.

0 Likes
Message 9 of 12

zenop
Advocate
Advocate

@Max Tarpini you legend! I'll try that out when I get home. This is super helpful man, much appreciated.

0 Likes
Message 10 of 12

zenop
Advocate
Advocate

I appreciate the input but in this case OSL can't be used.

0 Likes
Message 11 of 12

zenop
Advocate
Advocate

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.

0 Likes
Message 12 of 12

maxtarpini
Collaborator
Collaborator

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.

0 Likes