knhan930 Posted October 26, 2012 Report Share Posted October 26, 2012 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. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted October 27, 2012 Report Share Posted October 27, 2012 % 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 maehne 1 Quote Link to comment Share on other sites More sharing options...
knhan930 Posted October 30, 2012 Author Report Share Posted October 30, 2012 Thank you. It's helpful. Quote Link to comment Share on other sites More sharing options...
taog Posted February 18, 2019 Report Share Posted February 18, 2019 I've tried link against the static library libsystemc.a, I got error below: /home/taog/tools/systemc-2.3.1/lib-linux64//libsystemc.a(sc_main_main.o): In function `sc_elab_and_sim': /home/taog/tools_src/systemc-2.3.1a/objdir/src/sysc/kernel/../../../../src/sysc/kernel/sc_main_main.cpp:84: undefined reference to `sc_main' I need to pack a library based on SystemC, adding a empty sc_main in a library is weld. Quote Link to comment Share on other sites More sharing options...
maehne Posted February 18, 2019 Report Share Posted February 18, 2019 37 minutes ago, taog said: I've tried link against the static library libsystemc.a, I got error below: /home/taog/tools/systemc-2.3.1/lib-linux64//libsystemc.a(sc_main_main.o): In function `sc_elab_and_sim': /home/taog/tools_src/systemc-2.3.1a/objdir/src/sysc/kernel/../../../../src/sysc/kernel/sc_main_main.cpp:84: undefined reference to `sc_main' I need to pack a library based on SystemC, adding a empty sc_main in a library is weld. Either you as the library author or the user of that library will need to provide at least an empty implementation of sc_main() to satisfy the linker. There is no way around it. I would like to also suggest that you update your SystemC installation to the latest version 2.3.3. Quote Link to comment Share on other sites More sharing options...
taog Posted February 19, 2019 Report Share Posted February 19, 2019 11 hours ago, maehne said: Either you as the library author or the user of that library will need to provide at least an empty implementation of sc_main() to satisfy the linker. There is no way around it. I would like to also suggest that you update your SystemC installation to the latest version 2.3.3. Get it, thank you, maehne. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.