Jump to content
katang

What is SystemC library special in?

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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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..

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

Hello @Elvis Shera,

It seems your SystemC library has been build with different C++ standard flag.

Can you post the output of following commands?:

# Compiler version you are using
g++ -v

# Library Properties:
nm -C $SYSTEMC_HOME/lib-linux64/libsystemc.so | grep api_version

Regards,

Ameya Vikram Singh

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Hello @Elvis Shera,

The G++ Compiler 7.3.0 by default enables C++14, and your SystemC library is build using C++14 standard.

You can change the line in your CMakeLists.txt to be:

set(CMAKE_CXX_STANDARD 14)  # enable C++14 standard

and it should work now.

Hope this helps.

Regards,

Ameya Vikram Singh

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×