Jump to content

What is SystemC library special in?


katang

Recommended Posts

I am working in a CMake environment, compiling, building, documenting and packaging my app. It works fine, except when SystemC is involved. The other libraries, including flex, Qt, gtest, etc. do not cause similar messages.

The other options work fine also for SystemC, but when attempting to make a Debian package, I receive the message

CPack: Create package
CPackDeb: - Generating dependency list
CMake Error at /usr/share/cmake-3.5/Modules/CPackDeb.cmake:530 (message):
  CPackDeb: dpkg-shlibdeps: 'dpkg-shlibdeps: warning: binaries to analyze
  should already be installed in their package's directory

  dpkg-shlibdeps: error: couldn't find library libsystemc-2.3.1.so needed 

What is special with SystemC, or what do I wrong?

Link to comment
Share on other sites

The installation layout of the SystemC proof-of-concept library deviates from the standard layout commonly used on Linux. Therefore, SystemC is usually installed to a directory under /opt/. This may cause your problem with CPack. However, an experimental CMake-based build system has been added to the SystemC 2.3.2 public review release. Instructions for using it are contained in the text file cmake/INSTALL_USING_CMAKE. When building and installing SystemC using CMake, also the necessary configuration files for locating SystemC are installed. For example, a minimal CMakeLists.txt to compile the simple_perf SystemC example as a stand-alone application would be:

cmake_minimum_required(VERSION 3.1)
project(simple_perf CXX)

set (CMAKE_PREFIX_PATH /opt/systemc)
find_package(SystemCLanguage CONFIG REQUIRED)

set (CMAKE_CXX_STANDARD ${SystemC_CXX_STANDARD} CACHE STRING
     "C++ standard to build all targets. Supported values are 98, 11, and 14.")
set (CMAKE_CXX_STANDARD_REQUIRED ${SystemC_CXX_STANDARD_REQUIRED} CACHE BOOL
     "The with CMAKE_CXX_STANDARD selected C++ standard is a requirement.")

add_executable(simple_perf simple_perf.cpp)
target_link_libraries(simple_perf SystemC::systemc)

Please, give it a try and provide feedback so that remaining issues can be resolved.

Note though that CPack hasn't been considered so far in the implementation of the CMake-based build system for SystemC. Therefore, feedback on this aspect is even more interesting.

Link to comment
Share on other sites

  • 10 months later...
  • 6 months later...
5 hours ago, Elvis said:

What if the SystemC installation has not been done via Cmake?  There must be a way to locate the libraries (given that systemc has been installed in a local directory) for the linking process. In that case what are the instruction to achieve this ?

In that case you will have to specify library paths manually.

Link to comment
Share on other sites

in a manually made Makefile i have the following:

 

# target architecture
TARGET_ARCH     = linux64

# specify paths
SYSTEMC_INC_DIR = $(SYSTEMC_HOME)/include
SYSTEMC_LIB_DIR = $(SYSTEMC_HOME)/lib-$(TARGET_ARCH)

LDFLAGS = "-Wl,-rpath,$(SYSTEMC_LIB_DIR)" -L$(SYSTEMC_LIB_DIR) -lsystemc -lm

 

the last taking care of the linking phase... I am new to cmake and I can see that is a nice build system but I am having a mental time to specify the same things in the CMakeLists.txt

Link to comment
Share on other sites

12 hours ago, Elvis Shera said:

What if the SystemC installation has not been done via Cmake?  There must be a way to locate the libraries (given that systemc has been installed in a local directory) for the linking process. In that case what are the instruction to achieve this ?

SystemC supports pkg-config as well and generates a corresponding systemc.pc file.  Of course, you still need to have the systemc.pc file somewhere in your PKG_CONFIG_PATH

For manual Makefiles, you can check the templates in examples/build-unix as a starting point.

Greetings from Duisburg,
  Philipp

Link to comment
Share on other sites

Thanks Philipp,

I already use Makefiles and these are ok. I also understand that via cmake build/install the cmake related configuration are generates so is easier then.

My question goes in the direction of: If I don't use cmake to install systemC, how can I still use cmake for a systemc project ? I think I am almost done but the linking part is failing.

The Makefile example I reported is already in use and working so the question is how do I translate that information for the Linker in an equivalent description for CMakeLists.txt?

It should be trivial but it seems I am missing some steps..

Link to comment
Share on other sites

Hello @Elvis Shera,

Can you post the CMakeLists.txt you have for your example?

It would be easier to suggest a solution.

But If you want to take a look at minimal example of using CMake throughout for SystemC library, as well as building models you can have a look here:

https://github.com/AmeyaVS/SystemC_ramblings/tree/master/src/01_SystemCTest

Though to be honest it has been sometime since I have updated these, but basic concept are same.

Hope it helps.

Regards,

Ameya Vikram Singh

Link to comment
Share on other sites

Hi Ameya,

here is my file:

==========================================================

cmake_minimum_required(VERSION 3.1) # setting this is required

project(xor)                        # this sets the project name

SET(TARGET_ARCH "linux64")
set(CMAKE_PREFIX_PATH $ENV{SYSTEMC_HOME})
SET(SYSTEMC_INC_DIR "${CMAKE_PREFIX_PATH}/include")
SET(SYSTEMC_LIB_DIR "${CMAKE_PREFIX_PATH}/lib-${TARGET_ARCH}")


include_directories(${PROJECT_SOURCE_DIR}/inc ${SYSTEMC_INC_DIR})
file(GLOB SOURCES "src/*.cpp")


set(CMAKE_CXX_STANDARD 11)  # enable C++11 standard
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -c -Wall")

add_executable(scapp ${SOURCES})


link_directories(${SYSTEMC_LIB_DIR})
target_link_libraries(scapp systemc)

==========================================================

compilation works and it is finding the systemc include files but the linking not yet. As you can see from the error i get.

c++: warning: CMakeFiles/scapp.dir/src/monitor.cpp.o: linker input file unused because linking not done

you are using find_package in your example which suggest your entire installation of the systemc libraries has been done via cmake.  In my case I have not followed the cmake approach hence the find_package is not working in my case.

Link to comment
Share on other sites

Hello @Elvis Shera,

It seems the following line seems suspicious:

28 minutes ago, Elvis Shera said:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -c -Wall")

The compiler flag -c is only required by gcc to create object files from translation units.

Here's a quote from gcc documentation:

For example, the -c option says not to run the linker.  Then the output consists of object files output by the assembler.

Try removing the option -c and try again. CMake would already handle the scenario internally.

Hope this helps.

Regards,

Ameya Vikram Singh

Link to comment
Share on other sites

I did that and it has at least improved the messaging. I also added the following lines:

 

add_library(systemc SHARED IMPORTED)
set_property(TARGET systemc PROPERTY IMPORTED_LOCATION "/home/Tools/SystemC/systemc-2.3.3/lib-linux64/libsystemc.so")

 

now the problem i am seeing is the following:

[100%] Linking CXX executable scapp
CMakeFiles/scapp.dir/src/main.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':
/home/Tools/SystemC/systemc-2.3.3/include/sysc/kernel/sc_ver.h:182: undefined reference to `sc_core::sc_api_version_2_3_3_cxx201103L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_3_cxx201103L(sc_core::sc_writer_policy)'

maybe for the more SystemC experts?

Maybe the setup is not there yet as my sc project runs ok with the conventional make approach.

 

Link to comment
Share on other sites

g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)

 

 

 

nm -C $SYSTEMC_HOME/lib-linux64/libsystemc.so | grep api_version
00000000000bef70 T 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)
00000000000bef70 T 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)
00000000003fb440 b 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)::default_writer_policy_config
00000000003fb444 b 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)::default_writer_policy_config_seen

 

Thanks for looking at this,

Elvis

Link to comment
Share on other sites

  • 4 months later...

Hi! I don't know if this belongs here, but since you were talking about CMakes I guess it does. Currently I'm trying to build a simple ALU project with CMake and CLion on Windows 10 using the Cygwin toolchain. Currently I'm able to compile and even run my build, but when executing I only get:

 

C:\Users\egroj97\Code\C++\SystemC\coco3000_nuevaversion\alu\cmake-build-debug\alu.exe

        SystemC 2.3.3-Accellera --- Mar 21 2019 20:34:49
        Copyright (c) 1996-2018 by all Contributors,
        ALL RIGHTS RESERVED

Process finished with exit code 0

 

Do you by any reason know why does this happen?

CMake:
 

cmake_minimum_required(VERSION 3.1)

project(alu)

find_package(SystemCLanguage CONFIG REQUIRED)
set(TARGET_ARCH "cygwin64")
set(CMAKE_PREFIX_PATH $ENV{SYSTEMC_HOME})
set(SYSTEMC_INC_DIR "${CMAKE_PREFIX_PATH}/include")
set(SYSTEMC_LIB_DIR "${CMAKE_PREFIX_PATH}/lib-${TARGET_ARCH}")


include_directories(${PROJECT_SOURCE_DIR} ${SYSTEMC_INC_DIR})
file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/*.cpp")


set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall")

add_executable(alu main.cpp testbench.cpp)

link_directories(${SYSTEMC_LIB_DIR})
target_link_libraries(alu SystemC::systemc)

 

Link to comment
Share on other sites

On 3/22/2019 at 4:26 AM, egroj97 said:

Hi! I don't know if this belongs here, but since you were talking about CMakes I guess it does. Currently I'm trying to build a simple ALU project with CMake and CLion on Windows 10 using the Cygwin toolchain. Currently I'm able to compile and even run my build, but when executing I only get:

 


C:\Users\egroj97\Code\C++\SystemC\coco3000_nuevaversion\alu\cmake-build-debug\alu.exe

        SystemC 2.3.3-Accellera --- Mar 21 2019 20:34:49
        Copyright (c) 1996-2018 by all Contributors,
        ALL RIGHTS RESERVED

Process finished with exit code 0

 

Do you by any reason know why does this happen?

This output does not hint for any problem. What output do you expect from your alu model? You need to implement explicitly any debug output in your SystemC model using, e.g., the SC_REPORT_* macros. Tracing of signal using the sc_trace() mechanism won't cause any additional output on the console either. If you expect some output, you will have to share the code of a minimal working example exposing your problem.

On 3/22/2019 at 4:26 AM, egroj97 said:

CMake:
 


cmake_minimum_required(VERSION 3.1)

project(alu)

find_package(SystemCLanguage CONFIG REQUIRED)
set(TARGET_ARCH "cygwin64")
set(CMAKE_PREFIX_PATH $ENV{SYSTEMC_HOME})
set(SYSTEMC_INC_DIR "${CMAKE_PREFIX_PATH}/include")
set(SYSTEMC_LIB_DIR "${CMAKE_PREFIX_PATH}/lib-${TARGET_ARCH}")


include_directories(${PROJECT_SOURCE_DIR} ${SYSTEMC_INC_DIR})
file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/*.cpp")


set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall")

add_executable(alu main.cpp testbench.cpp)

link_directories(${SYSTEMC_LIB_DIR})
target_link_libraries(alu SystemC::systemc)

 

Your CMakeLists.txt looks mostly fine. However, it contains several unnecessary lines. After finding SystemC using find_package, you only need to make sure that your executable target is linked against the SystemC::systemc target using the target_link_libraries(alu SystemC::systemc) call. CMake retrieves from this target automatically any necessary compiler flags, preprocessor definitions, include paths, and library paths, which previously needed to be set up by hand. So, your minimal CMake file could look something like:

cmake_minimum_required(VERSION 3.1)

project(alu)

find_package(SystemCLanguage CONFIG REQUIRED)

# # Setting the C++ standard from the SystemC_CXX_STANDARD variable may be still
# # needed to compile without. So, in case of errors, try to uncomment the
# # following two set (...) commands. The experimental CMake-based build system
# # of the SystemC PoC implementation needs some updates to simplify further
# # building SystemC application using CMake by using features introduced in
# # CMake >3.11, which enable specifying even better the build and usage requirements
# # of a library or executable.
# set (CMAKE_CXX_STANDARD ${SystemC_CXX_STANDARD} CACHE STRING
       "C++ standard to build all targets. Supported values are 98, 11, and 14.")
# set (CMAKE_CXX_STANDARD_REQUIRED ${SystemC_CXX_STANDARD_REQUIRED} CACHE BOOL
#      "The with CMAKE_CXX_STANDARD selected C++ standard is a requirement.")

add_executable(alu main.cpp testbench.cpp)
target_link_libraries(alu SystemC::systemc)

The Section 4 of cmake/INSTALL_USING_CMAKE file contains some more hints.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...