为 VS2013 安装 SystemC

Installing SystemC for VS2013

我正在使用 Windows 10 64 位机器和 Visual Studio Professional 2013,我想安装 SystemC。我下载了 SystemC 2.3.1 并尝试按照提供的 "Installation notes" 进行操作,但它们有点过时了。

首先,它说"for VS 2005 and higher on Windows 7 machines",但我使用的是Windows 10,尽管如此,我仍然试图遵循它。其次,包含 srclib 文件不能按照那里的说明进行,因为此方法在 VS2013 中已更改。通过 Tools->Options->Projects->VCC++ 方向选项卡似乎不再有全局设置。

现在,我能够成功构建 SystemC.sln 解决方案。但是,当我尝试构建示例项目时出现以下错误:

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

尽管我认为我已经在项目属性中正确指定了 srclib 目录。

谁能解释一下如何在 Windows 10 x64 上使用 VS2013 构建 SystemC?

更新:如果您将 CMake 与 Visual Studio 一起使用,请检查

目前我没有安装 MSVC2013,所以这里是适用于我的 MSVC2017 的步骤。

  1. http://accellera.org/downloads/standards/systemc
  2. 下载最新的 SystemC
  3. 在Visual Studio
  4. 中打开systemc-2.3.1a\msvc80\SystemC\SystemC.sln
  5. Visual Studio 将提供更新解决方案,单击确定。您可以忽略带有警告的报告。
  6. 在VS菜单栏中将配置设置为“Debug”“Win32”。 (在我的例子中已经默认选中)
  7. 生成解决方案 (F7)

    在控制台中,您可能会发现如下消息:

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

    你可以忽略它们。解决方案应该没有错误地构建:

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

  8. 因此,您将在 systemc-2.3 中得到 SystemC.lib。1a\msvc80\SystemC\Debug

现在您可以创建一些测试 SystemC 项目。

  1. 文件->新建->项目->Win32 控制台应用程序
  2. 在解决方案资源管理器中右键单击项目 -> 属性
  3. 在配置属性 -> C/C++ -> 常规 -> 附加包含目录

    添加路径到:\systemc-2.3.1a\src

  4. 在配置属性 -> C/C++ -> 代码生成 -> 运行time 库

    Select: Multi-threaded 调试 (/MTd)

  5. 在配置属性 -> C/C++ -> 语言 -> 启用 Run-Time 类型信息

    Select: 是 (/GR)

  6. 在配置属性 -> C/C++ -> 命令行 -> 其他选项中

    类型:/vmg

  7. 在配置属性 -> 链接器 -> 常规 -> 其他库目录中

    添加路径到:systemc-2.3.1a\msvc80\SystemC\Debug

  8. 在配置属性 -> 链接器 -> 输入 -> 附加依赖项中

    添加:SystemC.lib

现在是时候输入一些代码了。例如这个 "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;
}

stdafx.h中添加:

 #include <systemc.h>
  1. 构建项目,它将失败并显示:

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

gets 已从最新的 MSVC 中的 std 命名空间中删除,但这并不是真正需要的。 所以只需打开 systemc.h 并注释掉第 120 行:

//    using std::gets;
  1. 万一您收到关于 sprintf
  2. 的错误

_CRT_SECURE_NO_WARNINGS 添加到预处理器定义列表

  1. 重新构建。 运行 没有调试 (Ctrl+F5)。您应该在控制台上看到以下介绍测试:
    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 . . .

希望对您有所帮助