Compiling Metropolis with Microsoft Visual C++

In December, 2003, we used Microsoft Visual Studio 6.0 sp4 to compile the producers_consumer example.

Below is how we did it

  1. Download SystemC-2.0.1 from http://www.systemc.org and untar it so that it is adjacent to the Metropolis directory. It should be adjacent because the MSVC project files look for SystemC using a relative path. If SystemC is not adjacent to Metropolis, then you will need to adjust the path to the include files and libraries.
  2. Compile SystemC as per the instructions in the systemc-x.x/INSTALL file
  3. Currently, MSVC does not compile the Metropolis java files, so it is best if you follow the standard g++ installation as per $METRO/README.txt and then come back here to the MSVC installation.
  4. $METRO/src/metropolis/metamodel/backends/systemc requires getrusage() which is not usually part of Windows. To compile port_rusage.cpp under MSVC, you must download psapi.h and psapi.lib. To run, you probably need psapi.dll. The easiest way to obtain these files is to look for them on the web using Google.
    psapi.h and psapi.lib should be placed in $METRO/src/metropolis/metamodel/backends/systemc.
    psapi.dll should be placed in your C:\Windows directory.
  5. Start up Microsoft Visual Studio 6.0 and load the Metropolis System C Backend Workspace at $METRO/src/metropolis/metamodel/backends/systemc/systemc.dsw
  6. Build the project
  7. To test the installation, under Cygwin bash create the .cpp files for the producers_consumers example:
    cd $METRO/examples/producers_consumer
    make
    
  8. In Visual Studio, load the $METRO/examples/producers_consumer/producers_consumer.dsp file and build the producers_consumer executable. Under Microsoft Visual C, you might see:
    metro\examples\producers_consumer\sc_main.cpp(114) : error C2143: syntax error : missing ';' before '['
    metro\examples\producers_consumer\sc_main.cpp(117) : error C2143: syntax error : missing ';' before '['
    
    The solution is to change:
      _sb.enabledSynchEventPC = new (ProgramCounter**)[0];
    
    to
      _sb.enabledSynchEventPC = new (ProgramCounter**[0]);
    
    and
      _sb.enabledSynchEventPC[i] = new (ProgramCounter*)[_sb.numSynchEventEachGroup[i]];
    
    to
      _sb.enabledSynchEventPC[i] = new (ProgramCounter*[_sb.numSynchEventEachGroup[i]]); 
    
    
    

SystemC Regression tests Under Cygwin

  1. Download regtests-2.0.1.tar.gz from http://www.systemc.org and untar it
  2. Edit regtests-2.0.1/scripts/verify.pl and change the first line to
    #!/usr/bin/perl
    
    and the Cygwin version check line to
        } elsif ($uname_s eq "CYGWIN_NT-5.1" ) {
    
  3. Set SYSTEMC_HOME to point to your systemc-2.0.1 directory. I did:
    SYSTEMC_HOME=c:/cxh/src/systemc-2.0.1
    export SYSTEMC_HOME
    
  4. Set CXX to cl so that the testsuite knows to use Microsoft Visual C++
    CXX=cl
    export CXX
    
  5. Run all the tests
    cd regtests-2.0.l
    c:/cxh/src/regtests-2.0.1/scripts/verify.pl -no-cleanup -v systemc