-1

I'm trying to run SystemC on XCode on mac (using the standard Clang compiler). Depending on the language dialect, I get different error messages. If I use C++14, I get the error

No member named 'experimental' in namespace 'std'

If I use the standard c++17, I get the error message

Undefined symbols for architecture x86_64:
  "sc_core::sc_api_version_2_3_3_cxx201402L<&(sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_)>::sc_api_version_2_3_3_cxx201402L(sc_core::sc_writer_policy)", referenced from:
      ___cxx_global_var_init in main.o
ld: symbol(s) not found for architecture x86_64

A similar question has been answered, however, the answer was "One of the files didn't have cstdlib included as a header file", without specifying that file. Does anyone know why that error occurs or what the file with the missing header is?

Schottky
  • 1,549
  • 1
  • 4
  • 19
  • 1
    Seems like you have different `C++` standard compilation flags while building the SystemC library, and the final executable. Can you try and pass the following compiler flag to the compiler: `-std=c++14`? and, update if this helps – AmeyaVS Feb 11 '20 at 07:46
  • c++14 does not work. It gives me the error `No member named 'experimental' in namespace 'std'`. I don't get this error when I use c++17, but then the error mentioned above happens. – Schottky Feb 13 '20 at 18:39
  • What compiler are you using? – AmeyaVS Feb 14 '20 at 03:04
  • Apple Clang compiler (the one that comes with XCode) – Schottky Feb 14 '20 at 19:35
  • Can you update this info along with the compiler version in your question? – AmeyaVS Feb 15 '20 at 20:32

1 Answers1

1

For SystemC, the kernel and the model need to be compiled with the same set of modern C++ features enabled, see the RELEASENOTES and INSTALL files in the package. By default, the currently selected C++ standard of the compiler is used by SystemC (i.e. from -std=c++17).

To build SystemC for use across different C++ standard settings, explicitly define the preprocessor flag SC_CPLUSPLUS to the minimum version you need when building both, the kernel and your models.

For example

  • build SystemC with -std=c++11 (aka SC_CPLUSPLUS=201103L)
  • build your model with a newer C++ standard as you like, but add -DSC_CPLUSPLUS=201103L to your compiler flags.

Supported values for SC_CPLUSPLUS are:

  • 199711L (C++03, ISO/IEC 14882:1998, 14882:2003)
  • 201103L (C++11, ISO/IEC 14882:2011)
  • 201402L (C++14, ISO/IEC 14882:2014)
  • 201703L (C++17, ISO/IEC 14882:2017)

If SystemC 2.3.3 does not work with some version/configuration of the Xcode Clang compiler, you can consider opening an issue at https://github.com/accellera-official/systemc.

pah
  • 313
  • 1
  • 10
  • I have never done a lot with c++ and that stuff so I don't know if I read your answer correctly... I have built SystemC using: `../configure --with-arch-suffix= CXXFLAGS='-std=c++11'` and then calling `make install`. Then I went into XCode and added the argument to my compiler flags. Still, does not solve the issue... – Schottky Feb 16 '20 at 17:16
  • Two questions: (1) Did the SystemC installation succeed with these settings? (2) Did you add `-DSC_CPLUSPLUS=201102L` to your compiler flags when building your model? – pah Feb 17 '20 at 18:14
  • (1) I suppose so, There were no errors when building and all the files are there... (2) I hope everything I have to do is add that flag to the section where it says additional Compiler Flags, so I should have done that as well – Schottky Feb 18 '20 at 00:13
  • My fault, I had a typo in the `SC_CPLUSPLUS` example value, updated post. – pah Feb 19 '20 at 06:27
  • Thank you very much! That was the issue. Does that only work if you use the dynamic SystemC library? If I add the static library (libsystemc.a), it gives me an error (library ... .dylib not loaded). If I add the dynamic library, the error obviously vanishes. – Schottky Feb 19 '20 at 11:36
  • This is independent of shared vs. dynamic linking. – pah Feb 19 '20 at 16:54