Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Compiling shaders using mingw

11 REPLIES 11
Reply
Message 1 of 12
zenop
488 Views, 11 Replies

Compiling shaders using mingw

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?

Tags (1)
Labels (1)
11 REPLIES 11
Message 2 of 12
hitecom8172
in reply to: zenop

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

Message 3 of 12
Stephen.Blair
in reply to: zenop

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



// Stephen Blair
// Arnold Renderer Support
Message 4 of 12
maxtarpini
in reply to: zenop

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

Message 5 of 12
zenop
in reply to: zenop

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

Message 6 of 12
zenop
in reply to: zenop

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.

Message 7 of 12
hitecom8172
in reply to: zenop

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

Message 8 of 12
maxtarpini
in reply to: zenop

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.

Message 9 of 12
zenop
in reply to: zenop

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

Message 10 of 12
zenop
in reply to: hitecom8172

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

Message 11 of 12
zenop
in reply to: zenop

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.

Message 12 of 12
maxtarpini
in reply to: zenop

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report