DavidA Posted January 8, 2021 Report Share Posted January 8, 2021 Hi, I am building a SystemC application on Centos 7 using gcc 7.3.1 (devtoolset-7). Linkage of my application fails with error: main.cpp:(.text.startup+0x2e): undefined reference to `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)' I can see that this error has been discussed in other forum topics and is caused by a mismatch of the C++ Standard. Therefore, I have checked that I am building both SystemC and the application using C++14. But I still see the error. I build SystemC 2.3.3 as follows: $ cmake -DCMAKE_CXX_STANDARD=14 -DBUILD_SHARED_LIBS=OFF .. and the link command for the application is: $ /opt/rh/devtoolset-7/root/usr/bin/g++ -O3 -DNDEBUG -Wl,--export-dynamic -rdynamic CMakeFiles/zodiac. dir/Kernel/main.cpp.o -o zodiac -Wl,-whole-archive /data/daldrich/systemc-2.3.3/systemc-2.3.3/build/systemc-2.3.3-install/lib64/libsystemc .a -Wl,--no-whole-archive,--as-needed -Wl,--whole-archive,--export-dynamic Kernel/libKernel.a -Wl,--no-whole-archive -ldl -pthread Here is the full error message: CMakeFiles/zodiac.dir/Kernel/main.cpp.o: In function `_GLOBAL__sub_I_sc_main': main.cpp:(.text.startup+0x2e): undefined reference to `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)' collect2: error: ld returned 1 exit status What am I doing wrong? Best regards, David Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted January 8, 2021 Report Share Posted January 8, 2021 Hello @DavidA I don't see the "-std=c++14" in your application build command line. Regards, Ameya Vikram Singh Quote Link to comment Share on other sites More sharing options...
DavidA Posted January 8, 2021 Author Report Share Posted January 8, 2021 Sorry, I didn't show the application compile command: /opt/rh/devtoolset-7/root/usr/bin/g++ -DSYSTEMC -Dzodiac_EXPORTS -I../../Kernel -I/data/daldrich/systemc-2.3.3/systemc-2.3.3/src -O3 - DNDEBUG -Wall -pedantic -pthread -std=c++14 -MD -MT CMakeFiles/zodiac.dir/Kernel/main.cpp.o -MF CMakeFiles/zodiac.dir/Kernel/main.cpp.o.d - o CMakeFiles/zodiac.dir/Kernel/main.cpp.o -c ../../Kernel/main.cpp So I do specify "-std=c++14" there. And the link command repeated from original post: /opt/rh/devtoolset-7/root/usr/bin/g++ -O3 -DNDEBUG -Wl,--export-dynamic -rdynamic CMakeFiles/zodiac.dir/Kernel/main.cpp.o -o zo diac -Wl,-whole-archive,-export-dynamic,-no-as-needed /data/daldrich/systemc-2.3.3/systemc-2.3.3/build/systemc-2.3.3-install/lib64/libsyste mc.a -Wl,--no-whole-archive,--as-needed -Wl,--whole-archive,--export-dynamic Kernel/libKernel.a -Wl,--no-whole-archive -ldl -pthread (I am assuming that "-std=c++14" isn't needed in the link command). Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted January 8, 2021 Report Share Posted January 8, 2021 Hello @DavidA Can you post the output of the following command: nm -C $SYSTEMC_HOME/lib/libsystemc.so | grep sc_api_version Regards Ameya Vikram Singh Quote Link to comment Share on other sites More sharing options...
DavidA Posted January 8, 2021 Author Report Share Posted January 8, 2021 I am using a static library. Here is the output: $ nm -C /data/daldrich/systemc-2.3.3/systemc-2.3.3/build/systemc-2.3.3-install/lib64/libsystemc.a | grep sc_api_version 0000000000000690 T 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) 0000000000000690 T 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) 0000000000000030 b 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)::default_writer_policy_config 0000000000000040 b 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)::default_writer_policy_config_seen Allen yang 1 Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted January 8, 2021 Report Share Posted January 8, 2021 Hello @DavidA It seems your SystemC library was built using C++11 standard. try changing the compile flag for the application to C++11 and see if this errors goes away. Regards, Ameya Vikram Singh Quote Link to comment Share on other sites More sharing options...
DavidA Posted January 8, 2021 Author Report Share Posted January 8, 2021 Hi @AmeyaVS Thanks for helping me. I rebuilt my application using C++11 and no error occured. So the question seems to be: why is my SystemC library built using C++11 standard, when I specified:$ cmake -DCMAKE_CXX_STANDARD=14 -DBUILD_SHARED_LIBS=OFF .. Best regards David Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted January 8, 2021 Report Share Posted January 8, 2021 Hello @DavidA It might be if you are reusing the build directory and cmake has cached the previous configuration. What Generator backend are you using from cmake?(make/ninja or others) Regards, Ameya Vikram Singh Quote Link to comment Share on other sites More sharing options...
DavidA Posted January 8, 2021 Author Report Share Posted January 8, 2021 Hi @AmeyaVS I've been careful to clean the build directory each time: rm -rf * I'm using 'make' but have ninja available. Quote Link to comment Share on other sites More sharing options...
DavidA Posted January 8, 2021 Author Report Share Posted January 8, 2021 The cached value is 14, but it gets built with 11: $ cmake -L .. | grep CXX -- CMAKE_CXX_STANDARD = 14 -- CMAKE_CXX_STANDARD_REQUIRED = ON CMAKE_CXX_STANDARD:STRING=14 Quote Link to comment Share on other sites More sharing options...
DavidA Posted January 11, 2021 Author Report Share Posted January 11, 2021 I fixed this by specifying the devtoolset-7 g++ compiler to CMake: $ cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/g++ .. The problem was caused by CMake using the default Centos 7 g++ compiler (v.4.8.5) which presumably doesn't support C++14. 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.