Jump to content
knhan930

SystemC 2.3.0 with main()

Recommended Posts

Another issue I have is that I have a simple C++ code that uses only SystemC datatypes from SystemC library like below.

#include "systemc.h"


int main() {
 sc_uint<8> a, b;
 sc_uint<9> z;

 z = a + b;
}

It’s working with SystemC 2.2.0, but there is a link error with SystemC 2.3.0. I used the general compile command with GCC 4.2.2:

% g++ -I$SYSTEMC/include test.cpp –L$SYSTEMC/lib-linux64 -lsystemc
…/systemc-2.3.0/lib-linux64/libsystemc.so: undefined reference to `sc_main' collect2: ld returned 1 exit status

I wonder if SystemC 2.3.0 disables to use main() at all, which was ok with SystemC 2.2.0. It may cause the compatibility issue, so I would like to know how to remove the link error. Thank you.

Share this post


Link to post
Share on other sites

% g++ -I$SYSTEMC/include test.cpp –L$SYSTEMC/lib-linux64 -lsystemc
…/systemc-2.3.0/lib-linux64/libsystemc.so: undefined reference to `sc_main' collect2: ld returned 1 exit status

If you look at the error message more closely, the problem is not caused by the existence of your "main" function, but by the missing sc_main function. The main reason for this is the preferred use of the dynamic library since SystemC 2.3.0. The dynamic libraries needs the sc_main symbol to be present, as you cannot decide during the (dynamic) linking step, if this function is actually called or not.

I wonder if SystemC 2.3.0 disables to use main() at all, which was ok with SystemC 2.2.0. It may cause the compatibility issue, so I would like to know how to remove the link error. Thank you.

Two solutions are possible

  • link against the static library libsystemc.a (e.g. by moving libsystemc.so out of the way)
  • add an (empty) sc_main

Greetings from Oldenburg,

Philipp

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

×