accellera-official / systemc

SystemC Reference Implementation
https://systemc.org/overview/systemc/
Apache License 2.0
451 stars 145 forks source link

Undefined reference to the `sc_core::sc_api_version_2_3_4_XXX` .... #21

Closed AbdManian closed 2 years ago

AbdManian commented 2 years ago

SystemC fails to link. Platform Linux, G++ 9.3.0 Built with cmake version 3.16.3

Get link error building empty application.

/usr/bin/ld: /tmp/ccVw0j7V.o: in function `__static_initialization_and_destruction_0(int, int)':
sample.cpp:(.text+0x7e): undefined reference to `sc_core::sc_api_version_2_3_4_cxx201402L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_4_cxx201402L(sc_core::sc_writer_policy, bool)'
collect2: error: ld returned 1 exit status

Sample code: cmd: g++ sample.cpp -ISYSC_DIR -lsystemc -LSYSC_LIB_DIR

#include "systemc"
#include <iostream>
int main()
{
    std::cout << "Hello world\n";
    return 0;
}

Also mention I have same issue in Windows platform with MinGW.

AmeyaVS commented 2 years ago

This has already being discussed in SystemC forum. Your build command is missing the correct C++ Standard flag with which the SystemC kernel was compiled with.

Refere here for details: https://forums.accellera.org/topic/6792-how-to-fix-undefined-reference-to-sc_disable_virtual_bind_undefined_/?tab=comments#comment-18135

AbdManian commented 2 years ago

This has already being discussed in SystemC forum. Your build command is missing the correct C++ Standard flag with which the SystemC kernel was compiled with.

Refere here for details: https://forums.accellera.org/topic/6792-how-to-fix-undefined-reference-to-sc_disable_virtual_bind_undefined_/?tab=comments#comment-18135

Thank you. As a record the issue fixed by using cmake -DCMAKE_CXX_STANDARD=14 -DBUILD_SHARED_LIBS=OFF ..

AmeyaVS commented 2 years ago

@AbdManian , you can go ahead and close the issue.

Briwisdom commented 3 months ago

fixed this problem by setting CMakeLists.txt : set(CMAKE_CXX_STANDARD 14), (change 17 to 14)