5

I am using Windows 10 64-bit machine with Visual Studio Professional 2013 and I want to install SystemC. I downloaded SystemC 2.3.1 and I tried following the "Installation notes" provided but they're slightly outdated.

For one, it says "for VS 2005 and higher on Windows 7 machines" but I am using Windows 10, nevertheless I still tried to follow it. Second, the inclusion of src and lib files cannot be followed as stated there since this method was changed in VS2013. There seems to be no global setting anymore via Tools->Options->Projects->VCC++ directions tab.

Now, I was able to successfully buiold the SystemC.sln solution. However, when I tried to build an example project I got the following error:

LINK : fatal error LNK1104: cannot open file 'C:\Users\Andrew\Downloads\systemc-2.3.1a\systemc-2.3.1a\msvc80\SystemC\Debug.obj'

Even though I think I've correctly specified the src and lib directories in the project properties.

Can anyone explain how to build SystemC with VS2013 on Windows 10 x64?

Javia1492
  • 862
  • 11
  • 28
  • I'm now using SystemC 2.3.1a in Visual Studio 2017 Community. When you create project you need to 1) add /vmg /MTd flags for in C/C++ options 2) Specify path to library in linker options. I can create a step-by-step answer for VS2017 if it helps. – random Feb 01 '17 at 22:21
  • If you can provide that it would be helpful. Whether or not it works for VS2013 im not sure, but I will try since everything else i've tried hasnt worked. – Javia1492 Feb 01 '17 at 22:30
  • Ok, stay tuned for next couple of hours. Please note that SystemC 2.3.2 with "official support" for VS2013 is coming this year. But I was using 2.3.1 in VS2013/2015 for years without much issues. – random Feb 01 '17 at 22:31
  • Yea i have to use 2.3.1 since its actually for a course im taking and he "recommends" using VS 2013 since newer versions have had issues according to him. I figured for the sake of simplicity ill do what he prefers in case i have issues later. – Javia1492 Feb 01 '17 at 22:34

2 Answers2

8

Update: if you use CMake with Visual Studio, check Setting up a SystemC project with CMake: undefined reference to `sc_core

Currently I have no MSVC2013 installed, so here are steps for MSVC2017 that worked for me.

  1. Download latest SystemC from http://accellera.org/downloads/standards/systemc
  2. Open systemc-2.3.1a\msvc80\SystemC\SystemC.sln in Visual Studio
  3. Visual Studio will offer to update solution, click ok. You can ignore report with warnings.
  4. In VS menu bar set configuration to “Debug“ “Win32”. (In my case was already selected by default)
  5. Build solution (F7)

    In console, you may find messages like:

    Unknown compiler version - please run the configure tests and report the results

    You can ignore them. Solution should build without errors:

    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

  6. As a result you will have SystemC.lib in systemc-2.3.1a\msvc80\SystemC\Debug

Now you can create some test SystemC project.

  1. File->New -> Project -> Win32 Console application
  2. Right click on project in solution explorer -> Properties
  3. In Configuration Properties -> C/C++ -> General-> Additional include directories

    Add path to: \systemc-2.3.1a\src

  4. In Configuration Properties -> C/C++ -> Code generation -> Runtime Library

    Select: Multi-threaded Debug (/MTd)

  5. In Configuration Properties -> C/C++ -> Language -> Enable Run-Time Type Information

    Select: Yes (/GR)

  6. In Configuration Properties -> C/C++ -> Command Line -> Additional options

    Type: /vmg

  7. In Configuration Properties -> Linker -> General -> Additional Library Directories

    Add path to: systemc-2.3.1a\msvc80\SystemC\Debug

  8. In Configuration Properties -> Linker -> Input -> Additional dependencies

    Add: SystemC.lib

Now it's time to type some code. For example this "Hello world":

#include "stdafx.h"

struct test_module : sc_module {
    SC_HAS_PROCESS(test_module);

    test_module(::sc_core::sc_module_name) {
        SC_THREAD(test_thread);
    }

    sc_signal<std::string>  message{ "message" };

    void test_thread() {
        message.write("Hello world!");
        wait(1, SC_NS);
        cout << message.read() << endl;
        sc_stop();
    }
};

int sc_main(int argc, char** argv)
{
    test_module tmod{ "tmod" };
    sc_start();
    return 0;
}

In stdafx.h add:

 #include <systemc.h>
  1. Build project, it will fail with:

    \systemc-2.3.1a\src\systemc.h(120): error C2039: 'gets': is not a member of 'std'

gets was removed from std namespace in latest MSVCs, but it is not really required. So just open systemc.h and comment out Line 120:

//    using std::gets;
  1. In case you got error about sprintf

Add _CRT_SECURE_NO_WARNINGS to list of preprocessor definitions

  1. Build again. Run without debugging (Ctrl+F5). You should see the following introduction test on your console:
    SystemC 2.3.1-Accellera --- Feb  1 2017 14:43:06
    Copyright (c) 1996-2014 by all Contributors,
    ALL RIGHTS RESERVED

    Hello world!

    Info: /OSCI/SystemC: Simulation stopped by user.
    Press any key to continue . . .

Hope that helps

random
  • 3,868
  • 3
  • 22
  • 39
  • Thanks! ill give it a try and let you know what happens. – Javia1492 Feb 01 '17 at 23:35
  • Ok so i just tried it and i got the following error: 1>c:\users\andrew\downloads\systemc-2.3.1a\systemc-2.3.1a\src\sysc\datatypes\int\sc_nbutils.h(151): error C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\stdio.h(356) : see declaration of 'sprintf' – Javia1492 Feb 02 '17 at 05:41
  • After adding _CRT_SECURE_NO_WARNINGS to the preprocessor definitions list i rebuilt and it passed! Thank you for the help! – Javia1492 Feb 02 '17 at 05:44
  • Looks like in my case it was already enabled by default. I've added it to answer, just in case someelse will encounter it. – random Feb 02 '17 at 17:55
0

A minor addition to random's answer above : make changes of step 10 also after step 4 (before build): In Configuration Properties -> C/C++ -> Code generation -> Runtime Library Select: Multi-threaded Debug (/MTd)

With this incremental change to random's answer, the overall method worked in VS2019 as well

code
  • 1
  • 1