Jump to content
agumon9

Building error 'undefined reference to..'

Recommended Posts

Hi!

 

I am having a problem with not being able to build any code that contains any usage of SCV functions.

 

This is a simple code that I am trying to build and run:

#include <scv.h>

int sc_main (int argc, char* argv[]) {
// Int data type
int data = 100;
// Get the bitwidth of the data
int bitwidth = scv_get_extensions(data).get_bitwidth();
cout << "Width of data is "<< bitwidth << endl;
cout << "Value in data is ";
// Get the value in data and print to stdio
scv_get_extensions(data).print();
return 0;
}

but it has a ton of errors, mostly repeating themselves.

This is a first couple of them:

Building target: proba.exe
Invoking: Cygwin C++ Linker
g++ -L"C:/systemc-2.3.1/lib-cygwin" -o "proba.exe"  ./apb_transaction.o   -lsystemc -lscv
C:/systemc-2.3.1/lib-cygwin/libscv.a(libscv_la-scv_introspection.o): In function `_scv_extension_rw_sc_signed::write(sc_dt::sc_signed const&)':
/cygdrive/c/scv-2.0.0/objdir/src/scv/../../../src/scv/scv_introspection.cpp:1090: undefined reference to `sc_dt::sc_signed::operator=(sc_dt::sc_signed const&)'
/cygdrive/c/scv-2.0.0/objdir/src/scv/../../../src/scv/scv_introspection.cpp:1090:(.text+0xee54): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `sc_dt::sc_signed::operator=(sc_dt::sc_signed const&)'
C:/systemc-2.3.1/lib-cygwin/libscv.a(libscv_la-scv_introspection.o): In function `_scv_extension_rw_sc_signed::assign(long)':
/cygdrive/c/scv-2.0.0/objdir/src/scv/../../../src/scv/scv_introspection.cpp:1090: undefined reference to `sc_dt::sc_signed::operator=(long)'
/cygdrive/c/scv-2.0.0/objdir/src/scv/../../../src/scv/scv_introspection.cpp:1090:(.text+0xf04e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `sc_dt::sc_signed::operator=(long)'
C:/systemc-2.3.1/lib-cygwin/libscv.a(libscv_la-scv_introspection.o): In function `_scv_extension_rw_sc_signed::assign(unsigned long)':
/cygdrive/c/scv-2.0.0/objdir/src/scv/../../../src/scv/scv_introspection.cpp:1090: undefined reference to `sc_dt::sc_signed::operator=(unsigned long)'
/cygdrive/c/scv-2.0.0/objdir/src/scv/../../../src/scv/scv_introspection.cpp:1090:(.text+0xf08a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `sc_dt::sc_signed::operator=(unsigned long)'

I am using Eclipse with Cygwin.

 

Share this post


Link to post
Share on other sites

Hello,

 

the error lies probably in the order you pass the libraries systemc and scv to the compiler/linker. Instead of specifying first "-lsystemc" and then "-lscv":

 

g++ -L"C:/systemc-2.3.1/lib-cygwin" -o "proba.exe"  ./apb_transaction.o   -lsystemc -lscv

 

you should specify first "-lscv" and then "-lsystemc":

 

g++ -L"C:/systemc-2.3.1/lib-cygwin" -o "proba.exe"  ./apb_transaction.o   -lsystemc -lscv

 

The reason is that the SCV library references functions and datatypes of the SystemC library. Therefore, the linker has to resolve symbols of the SCV library and then resolve the remaining symbols to the SystemC library, which stem from your program and the SCV library.

 

Best regards,

 

Torsten Mähne

Share this post


Link to post
Share on other sites

Hi: Related question, but a different platform.

On linux (x86_64):

  1. I've built systemC-2.3.2 with CXXFLAGS=' -std=c++11 '
  2. I've built scv_2.0.1 with CXXFLAGS=' -std=c++11  --with-systemc=${myPath}/build/systemc-2.3.2
  3. I have main.cpp that compiles.

when I attempt to link: I get:

g++-4.8  -g -Wall -ggdb -std=c++11 -O0  -D GCC48  -Wall     ./main.o -lscv -lsystemc -lpthread -lm -L../build/systemc-2.3.2/lib-linux64  ../../CPP-NumericalMethods/libNumericalMethods.a ../build/systemc-2.3.2/lib-linux64/libscv.a ../build/systemc-2.3.2/lib-linux64/libsystemc.a  -o testCMD
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x50): undefined reference to `_scv_extension_util::get_short_name() const'
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x78): undefined reference to `_scv_extension_type_int::get_enum_details(std::list<char const*, std::allocator<char const*> >&, std::list<int, std::allocator<int> >&) const'
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x148): undefined reference to `_scv_extension_rw_int::assign(std::string const&)'

etc.....

./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x248): undefined reference to `_scv_extension_util::_set_name(std::string const&)'
../build/systemc-2.3.2/lib-linux64/libscv.so: undefined reference to `sc_core::sc_api_version_2_3_2_cxx199711L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx199711L(sc_core::sc_writer_policy)'


 

I can see the symbols defined in ../build/systemc-2.3.2/lib-linux64/libscv.so using the nm tool.

What am I missing....?

Thanks!

Peter

Share this post


Link to post
Share on other sites

Hello @pmeyeratdatest,

This line indicates the different command line parameters for the creation of the object files.

17 hours ago, pmeyeratdatest said:

../build/systemc-2.3.2/lib-linux64/libscv.so: undefined reference to `sc_core::sc_api_version_2_3_2_cxx199711L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx199711L(sc_core::sc_writer_policy)'

Also, why are the library specified on the command line twice?(i.e. [-lscv and -lsystemc] and [../build/systemc-2.3.2/lib-linux64/libscv.a and ../build/systemc-2.3.2/lib-linux64/libsystemc.a]

Can try this command, and let us know if the message changes

g++-4.8  -g -Wall -ggdb -std=c++11 -O0  -D GCC48  -Wall     ./main.o -o testCMD -L../build/systemc-2.3.2/lib-linux64 ../../CPP-NumericalMethods/libNumericalMethods.a ../build/systemc-2.3.2/lib-linux64/libscv.a ../build/systemc-2.3.2/lib-linux64/libsystemc.a -lscv -lsystemc -lpthread -lm

Hope this helps.

Regards,

Ameya Vikram Singh

Share this post


Link to post
Share on other sites

I can get the same errors if I only run with the shared objects.  I have tried creating a static library only with the .a files, but this introduces more linking errors.

../build/systemc-2.3.2/lib-linux64/libscv.a(libscv_la-scv_constraint.o): In function `__static_initialization_and_destruction_0':
/home/pmeyer/WORK/DA-Test/SW/SystemC/build/systemc-2.3.2/include/sysc/kernel/sc_ver.h:179: undefined reference to `sc_core::sc_api_version_2_3_2_cxx199711L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx199711L(sc_core::sc_writer_policy)'
../build/systemc-2.3.2/lib-linux64/libscv.a(libscv_la-scv_constraint_range.o): In function `__static_initialization_and_destruction_0':
/home/pmeyer/WORK/DA-Test/SW/SystemC/build/systemc-2.3.2/include/sysc/kernel/sc_ver.h:179: undefined reference to `sc_core::sc_api_version_2_3_2_cxx199711L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx199711L(sc_core::sc_writer_policy)'
../build/systemc-2.3.2/lib-linux64/libscv.a(libscv_la-scv_debug.o): In function `__static_initialization_and_destruction_0':
/home/pmeyer/WORK/DA-Test/SW/SystemC/build/systemc-2.3.2/include/sysc/kernel/sc_ver.h:179: undefined reference to `sc_core::sc_api_version_2_3_2_cxx199711L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx199711L(sc_core::sc_writer_policy)'
../build/systemc-2.3.2/lib-linux64/libscv.a(libscv_la-scv_expression.o): In function `__static_initialization_and_destruction_0':
/home/pmeyer/WORK/DA-Test/SW/SystemC/build/systemc-2.3.2/include/sysc/kernel/sc_ver.h:179: undefined reference to `sc_core::sc_api_version_2_3_2_cxx199711L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx199711L(sc_core::sc_writer_policy)'
../build/systemc-2.3.2/lib-linux64/libscv.a(libscv_la-scv_introspection.o): In function `__static_initialization_and_destruction_0':
/home/pmeyer/WORK/DA-Test/SW/SystemC/build/systemc-2.3.2/include/sysc/kernel/sc_ver.h:179: undefined reference to `sc_core::sc_api_version_2_3_2_cxx199711L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx199711L(sc_core::sc_writer_policy)'
../build/systemc-2.3.2/lib-linux64/libscv.a(libscv_la-scv_random.o):/home/pmeyer/WORK/DA-Test/SW/SystemC/build/systemc-2.3.2/include/sysc/kernel/sc_ver.h:179: more undefined references to `sc_core::sc_api_version_2_3_2_cxx199711L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx199711L(sc_core::sc_writer_policy)' follow
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x50): undefined reference to `_scv_extension_util::get_short_name() const'
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x78): undefined reference to `_scv_extension_type_int::get_enum_details(std::list<char const*, std::allocator<char const*> >&, std::list<int, std::allocator<int> >&) const'
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x148): undefined reference to `_scv_extension_rw_int::assign(std::string const&)'
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x178): undefined reference to `_scv_extension_rw_int::get_string() const'
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x248): undefined reference to `_scv_extension_util::_set_name(std::string const&)'
./main.o:(.rodata._ZTV19scv_extensions_baseIiE[_ZTV19scv_extensions_baseIiE]+0x50): undefined reference to `_scv_extension_util::get_short_name() const'
./main.o:(.rodata._ZTV19scv_extensions_baseIiE[_ZTV19scv_extensions_baseIiE]+0x78): undefined reference to `_scv_extension_type_int::get_enum_details(std::list<char const*, std::allocator<char const*> >&, std::list<int, std::allocator<int> >&) const'
./main.o:(.rodata._ZTV19scv_extensions_baseIiE[_ZTV19scv_extensions_baseIiE]+0x148): undefined reference to `_scv_extension_rw_int::assign(std::string const&)'
./main.o:(.rodata._ZTV19scv_extensions_baseIiE[_ZTV19scv_extensions_baseIiE]+0x178): undefined reference to `_scv_extension_rw_int::get_string() const'
./main.o:(.rodata._ZTV19scv_extensions_baseIiE[_ZTV19scv_extensions_baseIiE]+0x248): undefined reference to `_scv_extension_util::_set_name(std::string const&)'
./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x50): undefined reference to `_scv_extension_util::get_short_name() const'
./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x78): undefined reference to `_scv_extension_type_int::get_enum_details(std::list<char const*, std::allocator<char const*> >&, std::list<int, std::allocator<int> >&) const'
./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x148): undefined reference to `_scv_extension_rw_int::assign(std::string const&)'
./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x178): undefined reference to `_scv_extension_rw_int::get_string() const'
./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x248): undefined reference to `_scv_extension_util::_set_name(std::string const&)'
 

Share this post


Link to post
Share on other sites

Results with shared object files only:

 g++-4.8  -g -Wall -ggdb -std=c++11 -O0  -D GCC48  -Wall     ./main.o -o testCMD -L../build/systemc-2.3.2/lib-linux64 ../../CPP-NumericalMethods/libNumericalMethods.a -lscv -lsystemc -lpthread -lm

./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x50): undefined reference to `_scv_extension_util::get_short_name() const'
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x78): undefined reference to `_scv_extension_type_int::get_enum_details(std::list<char const*, std::allocator<char const*> >&, std::list<int, std::allocator<int> >&) const'
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x148): undefined reference to `_scv_extension_rw_int::assign(std::string const&)'
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x178): undefined reference to `_scv_extension_rw_int::get_string() const'
./main.o:(.rodata._ZTV14scv_extensionsIiE[_ZTV14scv_extensionsIiE]+0x248): undefined reference to `_scv_extension_util::_set_name(std::string const&)'
./main.o:(.rodata._ZTV19scv_extensions_baseIiE[_ZTV19scv_extensions_baseIiE]+0x50): undefined reference to `_scv_extension_util::get_short_name() const'
./main.o:(.rodata._ZTV19scv_extensions_baseIiE[_ZTV19scv_extensions_baseIiE]+0x78): undefined reference to `_scv_extension_type_int::get_enum_details(std::list<char const*, std::allocator<char const*> >&, std::list<int, std::allocator<int> >&) const'
./main.o:(.rodata._ZTV19scv_extensions_baseIiE[_ZTV19scv_extensions_baseIiE]+0x148): undefined reference to `_scv_extension_rw_int::assign(std::string const&)'
./main.o:(.rodata._ZTV19scv_extensions_baseIiE[_ZTV19scv_extensions_baseIiE]+0x178): undefined reference to `_scv_extension_rw_int::get_string() const'
./main.o:(.rodata._ZTV19scv_extensions_baseIiE[_ZTV19scv_extensions_baseIiE]+0x248): undefined reference to `_scv_extension_util::_set_name(std::string const&)'
./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x50): undefined reference to `_scv_extension_util::get_short_name() const'
./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x78): undefined reference to `_scv_extension_type_int::get_enum_details(std::list<char const*, std::allocator<char const*> >&, std::list<int, std::allocator<int> >&) const'
./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x148): undefined reference to `_scv_extension_rw_int::assign(std::string const&)'
./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x178): undefined reference to `_scv_extension_rw_int::get_string() const'
./main.o:(.rodata._ZTV23scv_extension_callbacksIiE[_ZTV23scv_extension_callbacksIiE]+0x248): undefined reference to `_scv_extension_util::_set_name(std::string const&)'
../build/systemc-2.3.2/lib-linux64/libscv.so: undefined reference to `sc_core::sc_api_version_2_3_2_cxx199711L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx199711L(sc_core::sc_writer_policy)'
 

Share this post


Link to post
Share on other sites

What I am wondering is:

Have I correctly built the respective systemC (2.3.2) and SCV (2.0.1) libraries?   (i.e. inclusion of std=c++11, optimizations, etc.)

Are there other compiler options I should be running with when building main and linking?  (-fPIC ???, etc).

Peter

Share this post


Link to post
Share on other sites

Hello @pmeyeratdatest,

Can you specify the C++ Standard flag to the compilation command line parameters.

# E.g.:

g++ -std=c++11 <your_project_sources.cpp> -c <other_compiler_flags>

Since It does not have any effect at link time.

Thanks and Regards,

Ameya Vikram Singh

Share this post


Link to post
Share on other sites

Hi:

 

The .configure files between systemC and scv behave very differently.  To get this to work, I had to do the following:

export CXX='g++ -std=c++11'
export CC='gcc -std=c++11'

 ./configure --libexecdir ${rootPath}/lib --with-systemc=${rootPath}/build/systemc-2.3.3

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

×