Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Compiling on Windows with MS VC Express 2008 and mr 3.6+

  1. #1
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    4,143

    Default Compiling on Windows with MS VC Express 2008 and mr 3.6+

    Great news. It is now easier to set up a 32-bit Windows machine to compile shaders. I just prepared for training class using MS VC Express 2008 for mental ray version 3.6.52.4.

    First of all, note that the most recent mental ray distributions have .msi installation executables that are different for different platforms. The installation now puts those by default into the directory with the platform name in it, for example,

    ray-standalone-3.6.52.4-nt-x64.msi >> C:/Program Files/mental images/mental ray nt-x64/
    ray-standalone-3.6.52.4-nt-x86-vc8.msi >> C:/Program Files/mental images/mental ray nt-x86-vc8/

    The former is for 64-bit while latter will install a 32-bit windows version of mental ray that is compatible with MS Visual C++ version 8 (the one that came out with Express 2005). Express 2008 is actually MS VC9, but it will work with mental ray compiled with VC8. I wil note in a separate post how to work with 64-bit, which is also now doable if you load the extra platform SDK announced in February 2008.

    So here's what I did to set up for compiling the mental ray training class for shader writing on a Windows XP platform. Assume we are setting up for compiling for the 32-bit nt-x86-vc8 platform.

    1) First, download 2008 Express. Go to:
    http://www.microsoft.com/express/download/

    Then choose the download for Visual C++ 2008 Express Edition. It should be pretty fast (not like the long SDK downloads necessary for 2005 Express once figure out what you really need for compiling with it. Oops, now with SP1 it takes a bit longer.)

    2) Copy io.h to unistd.h in C:\Program Files\Microsoft Visual Studio 9.0\VC\include. You may not need this depending on how you program. Those familiar Linux platforms and gcc might use unistd.h for low-level io. And you will need to do this if you are using sources from Andy Kopra's book, Writing mental ray Shaders.

    3) Next, we set up the command line for rendering.
    a) option 1. Reusing a desktop shortcut of the VS9 Command Prompt. The following makes a convenient desktop icon.
    Click right on Start>All Programs>Visual C++ 9.0 Express Edition>Visual Studio Tools>Visual Studio 2008 Command Prompt
    In that menu, choose Send to > Desktop (Create Shortcut) and rename the "Start in:" property to your shader directory.

    That should take care of most of the VS env variables. Now for mental ray, add these environment variables:

    Code:
    INCLUDE C:\Program Files\mental images\mental ray nt-x86-vc8\include
    
    LIB C:\Program Files\mental images\mental ray nt-x86-vc8\lib;
    Then, append the bin (executable) directory to end of existing PATH value:
    Code:
    PATH <existing PATH value>;C&#58;\Program Files\mental images\mental ray nt-x86-vc8\bin
    If you are using the demo installation from Andy Kopra's book, Writing mental ray Shaders, the files may be located in C:\Program Files\mental images\mental ray Demo 32-Bit Edition\ instead of C:\Program Files\mental images\mental ray nt-x86-vc8\

    b) option 2, Use the generic Command Prompt instead of the VS9 Command Prompt. We have to add the extra VS9 paths to the
    environment variables:

    Code:
    INCLUDE C&#58;\Program Files\Microsoft Visual Studio 9&#46;0\VC\INCLUDE;C&#58;\Program Files\Microsoft SDKs\Windows\v6&#46;0A\Include;C&#58;\Program Files\mental images\mental ray nt-x86-vc8\include
    
    LIB C&#58;\Program Files\Microsoft Visual Studio 9&#46;0\VC\LIB;C&#58;\Program Files\Microsoft SDKs\Windows\v6&#46;0A\Lib;C&#58;\Program Files\mental images\mental ray nt-x86-vc8\lib;
    And append to end of existing PATH value:
    Code:
    PATH <existing PATH value>;C&#58;\Program Files\mental images\mental ray nt-x86-vc8\bin;C&#58;\Program Files\Microsoft Visual Studio 9&#46;0\Common7\IDE;C&#58;\Program Files\Microsoft Visual Studio 9&#46;0\VC\BIN;C&#58;\Program Files\Microsoft Visual Studio 9&#46;0\Common7\Tools;C&#58;\WINDOWS\Microsoft&#46;NET\Framework\v3&#46;5;C&#58;\WINDOWS\Microsoft&#46;NET\Framework\v2&#46;0&#46;50727;C&#58;\Program Files\Microsoft Visual Studio 9&#46;0\VC\VCPackages;C&#58;\Program Files\Microsoft SDKs\Windows\v6&#46;0A\bin

    4) Compiling options for command line rendering. With VC 8 or VC 9, you must now use the mt command for building the manifest into the dll. Simply put, the dll will have built into it knowledge of where to find files on which it depends. In the manual that comes with mental ray, for NT x86, VC, it specifies the cl and link,

    Code:
    cl /c /O2 /G6 /MD /nologo /W3 -DWIN_NT example&#46;c
    link /nologo /nodefaultlib&#58;LIBC&#46;LIB /OPT&#58;NOREF /INCREMENTAL&#58;NO /DLL /OUT&#58;example&#46;dll example&#46;obj shader&#46;lib
    but not the mt command. So for NT x86, VC, for class we use:

    Code:
    cl /c /O2 /MD /nologo /W3 -DWIN_NT example&#46;c
    link /nologo /nodefaultlib&#58;LIBC&#46;LIB /OPT&#58;NOREF /INCREMENTAL&#58;NO /DLL /OUT&#58;example&#46;dll example&#46;obj shader&#46;lib
    mt&#46;exe -nologo -manifest example&#46;dll&#46;manifest -outputresource&#58;example&#46;dll;2
    Note that I removed the /G6, because it gave an ignored warning on my platform with 2008 Express (VC9).
    Note that there are quite a few more flags indicated in the build .bat files in the base shader source (which is installable from the msi. See Custom install option.) They are not all necessary, as some have built up from legacy code . If you wanted to add a few extra flags, you might try:
    /GF /GS- -D_SECURE_SCL=0

    One last note, if you are compiling C++ files, we would typically add these two flags to cl: /TP /EHsc. For example,

    Code:
    cl /TP /c /O2 /MD /nologo /W3 /EHsc -DWIN_NT example&#46;c
    Barton Gawboy

  2. #2
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    4,143

    Default Re: Compiling on Windows with MS VC Express 2008 and mr 3.6+

    OK. Now for 64-bit compiling for 2008 Express, you also have to load the Windows SDK, namely Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5. You can get it here:

    http://www.microsoft.com/downloads/deta ... laylang=en

    Now this one takes a long time to download, multiple hours on my Windows XP 64 machine. I ran it overnight after giving up watching it install.

    Also, to do native compiling, make sure you do the 2008 Express before the Windows SDK download. Otherwise, it will just be a cross compile according to what I've read.

    Now, for the command prompt, I re-use the Windows SDK command prompt that gets installed.
    Start>All Programs>Microsoft Windows SDK v6.1> CMD Shell

    And then type in:
    setenv /x64
    or
    setenv /release /x64

    if I want to use release options rather than debug default options

    Now, for 64-bit I add the extra command line cl flag -DBIT64, and otherwise keep them the same as above, eg
    Code:
    cl /c /O2 /MD /nologo /W3 -DWIN_NT -DBIT64 example&#46;c
    or for C++ cpp files:
    Code:
    cl /TP /c /O2 /MD /nologo /W3 -DWIN_NT /EHsc -DBIT64 example&#46;c
    The link and mt commands will be the same as the 32-bit.

    Note also that the path to the BIN, INCLUDE, and LIB directories will be different for this install:
    C:/Program Files/mental images/mental ray nt-x64/
    Barton Gawboy

  3. #3
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    4,143

    Default Re: Compiling on Windows with MS VC Express 2008 and mr 3.6+

    BTW, ever wonder what that ";2" is at the end of the mt command's arguments.

    It is an indicator that the manifest information goes into a dll. If it were a ";1", it is for putting the manifest into a exe.

    See this for developer details:
    http://blogs.msdn.com/junfeng/archive/2 ... abled.aspx
    Barton Gawboy

  4. #4
    Join Date
    Dec 2007
    Posts
    27

    Default Re: Compiling on Windows with MS VC Express 2008 and mr 3.6+

    Hi,

    My questions might be stupid since I am new in Shader programming in Mental ray.

    Alright, so basically I have the mental ray version 3.6.54.1 that comes with Andy Kopra book. My question is :

    1- I found the public-shaders-3.5.7.10 under resources on your website and there is a shader.lib but where is the include folder?.Are these all the libraries and headers I need to start compiling my my shaders in Visual c++ 2008( I have the full licence for VC 2008 so I don't want to use the express edition) .Do I need anything else?

    Thank you again for your time and I appreciate if you help me out.

    Hamed

  5. #5
    Join Date
    Dec 2007
    Posts
    27

    Default Re: Compiling on Windows with MS VC Express 2008 and mr 3.6+

    Hi ,

    Alright, I think I found the include folder in Mental ray that comes with Andy's book and I copied that in public-shaders-3.5.7.10.

    Good news,I Hooked it up to Maya and got two sliders (X,y) where I can add simply two colors together

    In include folder I have following files:

    shader.h
    mirelay.h
    mia_material_api.h
    mi_version.h
    geoshader.h

    and I have shader.lib in lib folder in public-shaders-3.5.7.10 which I downloaded from resources on lamrug website.

    [attachment=0:12n130dq]step2_3.jpg[/attachment:12n130dq]

    Thanks,


    Hamed
    Attached Images Attached Images

  6. #6
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    4,143

    Default Re: Compiling on Windows with MS VC Express 2008 and mr 3.6+

    Note to beware of mixing 3.5.7. with 3.6+. I don't understand why you are getting the 3.5.7.10 sources? Everything you need regarding shared libraries and include files should be included with the book. You could also look on the website www.writingshaders.com.

    It should also be explained and if not, there is a sub-forum here to ask questions.
    Barton Gawboy

  7. #7
    Join Date
    Dec 2007
    Posts
    27

    Default Re: Compiling on Windows with MS VC Express 2008 and mr 3.6+

    Hi,

    Sorry,yes. I missed the folder nt-x86-vc8 in the CD comes with the book.

    The only problem I have now is dealing with "miaux.h"

    When I compile the summed_noise_scalar ,compiler gives me an error saying it can;t find the following headers

    (Fetures.h, LETypes.h,OpenTypeTables.h)

    What are these and where Can I find them?

    Also,I already have io.h and unistd.h in my VC include file.

    Thank you so much again for your time,

    Hamed

  8. #8
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    4,143

    Default Re: Compiling on Windows with MS VC Express 2008 and mr 3.6+

    I don't know where those are. miaux does not explicitly depend on those.

    Do you have a command line shell window in your VC distribution, in which you could test the compilation?

    In Express, there is one you can reach from the startup menus.
    Barton Gawboy

  9. #9
    Join Date
    Dec 2007
    Posts
    27

    Default Re: Compiling on Windows with MS VC Express 2008 and mr 3.6+

    Hi ,

    I think I have the wrong unistd.h in my VS include folder. When I installed the MS VS 2008 on my machine there wasn't any unistd.h in the include folder.However,I could find IO.h there. I searched on google and found unistd.h and put it in my VS include folder.I found out later it was a wrong file ,and it is relying on other headers.

    Could you please tell me where I can get the unistd.h or if someone have it , please post it so I can download it and use it.

    Thanks so much in advance.

    Hamed

  10. #10
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    4,143

    Default Re: Compiling on Windows with MS VC Express 2008 and mr 3.6+

    I think I mention this above in step 2, but I'll repeat it here...

    Copy io.h to unistd.h in the same directory.
    Barton Gawboy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •