Results 1 to 10 of 18

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

Hybrid View

  1. #1
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    2,914

    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
    Training and Special Projects, NVIDIA ARC
    LAmrUG Forum Originator

  2. #2
    Join Date
    Feb 2010
    Posts
    1

    Default Files

    Hi

    I was woundering where i can get the msiand lib file for MR?

    >>INCLUDE C:\Program Files\mental images\mental ray nt-x86-vc8\include

    >>LIB C:\Program Files\mental images\mental ray nt-x86-vc8\lib;

Posting Permissions

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