Jump to content
ssingh.codesupport

SystemC linking problem in Ubuntu

Recommended Posts

Hello,

I am trying to execute a basic project in  SystemC-2.3.2 with:

1. Module with DUT (.h and .cpp file)

2. Testbench (.h and .cpp file)

3. Top module (main.cpp)

The version is : g++ --version
g++ (Ubuntu 7.3.0-16ubuntu3) 7.3.0

Due to some linking error, I get the following error while compiling.

g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=§SYSTEMC_HOME/lib-linux64 -o main main.cpp -lsystemc -lm

/tmp/ccKTqv2Y.o: In function `statem::statem(sc_core::sc_module_name)':
main.cpp:(....): undefined reference to `statem::controller()'

This error is consistent for all the SC_METHOD declarations. Please let me know where I am going wrong. Any suggestions are welcome.

 

Thank you!

 

 

 

Share this post


Link to post
Share on other sites

On the surface I would say you have a problem with your own code, but I cannot say much more because you did not share the code with us. At a minimum I would need to see main.cpp, but if you have other source files (e.g. state.cpp, which I would expect since any self-respecting C++ coder would put each class into its own CLASSNAME.cpp and CLASSNAME.h (or .hpp) file).

Note: This has nothing to do with Ubuntu and likely little to do with the SystemC version.

Share this post


Link to post
Share on other sites

I agree here with David, best would be to share the basic parts of your code as well as the complete commands and outputs

From your description you have your DUT and your testbench in a separate file. You should compile them (inlcuding your main.cpp) into .o files e.g. by running something like

g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -c <cpp file here>

and then link all .o file into your executable like:

g++ -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=§SYSTEMC_HOME/lib-linux64 -o main *.o -lsystemc -lm 

This is a basic C++ compile flow, see also here https://www.cprogramming.com/compilingandlinking.html or here: https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html

BR

Share this post


Link to post
Share on other sites

Yes I have a separate main file, a separate testbench and another module for the DUT. There was an issue with the linker path but it's resolved now. I also ran the installation commands once more for proper working of the library -libsystemc.a.

There is further issue with the result of the program which I better write in a new post as its a different topic.

 

Thanks a lot!

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

×