Jump to content

SystemC linking problem in Ubuntu

Recommended Posts


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!




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

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


Link to comment
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!

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.

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...