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

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

×