Installing SystemC using Microsoft Visual Studio 2005

Ok to be honest the reason I got my hands on eclipse once again was that I wanted to try out SystemC with that. To do that I have to compile the SystemC source code using Cygwin but I have failed doing that so I present you what I have accomplished so far. Cygwin will be covered in a future post maybe.

There are many installation guides around the web and most of them are lookalike but in my case none of them covered the issues I got into so this is my guide for the task.

First of all the Microsoft Visual Studio 2005 should be installed. This is trivial and as I have done it a long time ago I won’t get into details. To get SystemC you need to go to the official site of Open SystemC Initiative (here) go to downloads –> OSCI Standards and look for the systemc-2.2.0.tgz file. In it there is a systemc-2.2.0 folder with a ton of stuff. Unzip it in C:\ so that you have c:\systemc-2.2.0.

Once unzipping is finished go to c:\sustemc-2.2.0\msvc71\SystemC\ and open either the solution or the VS project file with visual studio 2005. (Some guides suggest the folder msvc60 that does exist but is empty…)

Once the studio is opened you have to build the project using debug and release configuration. As I have barely used MS Visual Studio I have no idea what that meant so I demonstrate it here in more detail in case others are like me Smile

visual_studio01

As seen in the picture above there is this tiny arrow that switches between debug and release. I first built the debug and afterwards the release. Now I could find the folders debug and release with a SystemC.lib file in each one of them in C:\systemc-2.2.0\msvc71\SystemC\.

To proceed I had to create an environmental variable called SYSTEMC that pointed to the above path. It was unclear where to create it I figured out that it should be done in the windows environmental variables. So: left click on computer –> properties –> advanced system settings –> environmental variables. There you can find user variables and system variables. It was not clear where to add it (I suspect it works fine just in user variables) so I added the same variable in both fields (variable name: SYSTEMC , variable value: c:\systemc-2.2.0\msvc71 ).

Most guides suggest that it works using the fir example found in an examples folder somewhere in the unzipped files. It is most unfortunate that the current example seems to be buggy. Once I tried to built it I got the following fatal error:

fatal error LNK1169: one or more multiply defined symbols found

and that is because there are two files ( main.cpp and main_rtl.cpp ) that contain the sc_main. I found a solution around the web suggesting that the removal of the main_rtl.cpp file from the project ends up with correct compile/link. I tried so but then I got an error message that the main_rtl.cpp was missing! So after some frustration I decided to try other examples like the fft and I found out that they built nicely! So I proceeded with the next big step: trying to make a SystemC project of my own.

I had some source files so I created a new project and added those files. Here are the changes needed to be done on order to make it work:

Right click on the project name –> properties.

From tab C/C++ / General :

  • Detect 64-bit Portability Issues –> No

From tab C/C++ / Preprocessor :

  • Add the definition: _CRT_SECURE_NO_DEPRECATE

From tab C/C++ / Code Generation:

  • For Debug built: Runtime Library –> Multi-threaded Debug(/MTd)
  • For Release built: Runtime Library –> Multi-threaded (/MT)

From tab C/C++ / Language

  • Enable Run-Time Type info –> Yes

From tab C/C++ / Command LIne

  • Add the command /vmg in Addition Options box

From tab Linker / Input

  • Write systemc.lib in additional dependences field.

To locate the headers and the libraries of SystemC (for any project the following should be done:

Tools –> Options –> Projects –> VC++ Directories

Choose Show Directories for: Library files

Select New and write: $(SYSTEMC)\SystemC\Debug

Choose Show Directories for: Include files

Select New and write: &(SYSTEMC)\\src

For the last one to work you also need to copy the source folder found in c:\systemc-2.2.0 in c:\systemc-2.2.0\msvc71\ .

With all the above you should be able to use SystemC with visual studio. Next: GTKWave viewer.

Advertisements

5 thoughts on “Installing SystemC using Microsoft Visual Studio 2005

  1. Thanks for the instructions. Very useful for me! I’ve successfully built systemC for Cygwin AND MinGW in the past, but this time I wanted to try VS.

    Using MS VS Express 2012 for Windows + systemc-2.3.0, I was getting a stream of errors when trying to build:

    C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xkeycheck.h(195): warning C4005: ‘for’ : macro redefinition
    C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xkeycheck.h(242): fatal error C1189: #error : The C++ Standard Library forbids macroizing keywords. Enable warning C4005 to find the forbidden macro.

    This got solved after I commented out sc_cmnhdr.h(75):

    #define for if( false ); else for

  2. Hi Amit!

    I changed from VS 2010 to VS 2012 – with a lot of this “… macroizing keyword …” errors in the same file.

    Your hint helps me to solve this strange errors in VS2012 and SystemC 2.3.0 -> many thanks.

    Best regards,
    Otmar

  3. steps for the first time:

    copy the systemC library folder to C-drive

    1.open Microsoft visual studio.

    2.file->open->project/solutions.

    3.select the file “SystemC.vcproj” which is located at “C:\systemc-2.3.1\msvc80\SystemC” (if only

    systemC folder was located in C drive).

    4.follow the wizard.

    5.make sure you have the Solution Explorer view opened – “View / Solution Explorer”.

    6.build the systemC project using F6 — it will create a folder Debug at location “C:\systemc-

    2.3.1\msvc80\SystemC” folder. (check debug folder)

    7.check “systemc.lib” was available in debug folder.

    steps to follow each time the project was created:

    1.create a new project “File–> new–> project”

    2.choose win32 console Application–>select /tick “empty project”(next step)

    3. right-click on “source files” folder and “Add->New Items”.

    4.select C++ file(.cpp), provide source code name

    5.click on “project”–>”properties”

    6. (optional)Check “configuration Properties–>general–>use of MFC –> is “USe standard WIndows

    Libraries” “.

    7. Project–>properties–>Configuration Properties–> Debugging–>Environment

    “SC_SIGNAL_WRITE_CHECK=DISABLE”.

    8. Project–>properties–>Configuration Properties–>C/C++ –>General –>Additional Include

    Directories “(add Path of src folder (C:\systemc-2.3.1\src)”.

    9. Project–>properties–>Configuration Properties–>C/C++ –>Preprocessor–>preprocessor

    Definitions ==(add at end) “_CRT_SECURE_NO_WARNINGS”.

    10. Project–>properties–>Configuration Properties–>C/C++ –>code Generation–> Runtime Library

    == Multi-Threaded Debug(/Mtd).

    11. Project–>properties–>Configuration Properties–>C/C++ –>command line == (add) “/vmg”.

    12. Project–>properties–>Configuration Properties–>Linker –> General–>additional Library

    Directories == “(add path of Debug folder-mostly C:\systemc-2.3.1\msvc80\SystemC\Debug)”.

    13. Project–>properties–>Configuration Properties–>Linker–>input–>Additional Dependencies ==

    add at end “systemc.lib”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s