Jump to content

error: ‘sc_port’ was not declared in this scope


Edward1110

Recommended Posts

Hi all,

I just installed systemc on my new computer with ubuntu. And I tried to run the code I wrote before which work perfectly fine on my other computer with Ubuntu.

But I got the error: ''jump_addr' was not declared in this scope for all my ports and arguments with 'sc_bv' and 'sc_lv' type.

Anyone knows what is going on, am I missing some thing in my system?

export SYSTEMC_HOME=/usr/local/systemc-2.3.2/

g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=$SYSTEMC_HOME/lib-linux64 -o hello pc.h -lsystemc -lm

that is the command I used

 

I tried to run several different code, all of them doesn't work, I also tried to install different versions of systemc but the problem still exist.

anyway I put one of the codes in the attachment

regards,

Edward

pc.h

Link to comment
Share on other sites

Hello @Edward1110,

Firstly why are you trying to compile a header file with missing definition of the method "pc_main".

Can you post the exact error log that you get from the console output while running the command?(Use the code block to post the console output.)

Here is the output from the command on my system:(Kindly Note I am using CMake to build the SystemC library.)

// Command executed:
// $ g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib -Wl,-rpath=$SYSTEMC_HOME/lib -o hello pc.h -lsystemc -lm

pc.h:10:19: error: jump_addr was not declared in this scope
  sc_in<sc_lv<12>> jump_addr;
                   ^
pc.h:10:19: error: template argument 1 is invalid
pc.h:10:8: error: template argument 1 is invalid
  sc_in<sc_lv<12>> jump_addr;
        ^
pc.h:11:19: error: branch_length was not declared in this scope
  sc_in<sc_bv<12>> branch_length;
                   ^
pc.h:11:19: error: template argument 1 is invalid
pc.h:11:8: error: template argument 1 is invalid
  sc_in<sc_bv<12>> branch_length;
        ^
pc.h:13:20: error: pc_o was not declared in this scope
  sc_out<sc_bv<12>> pc_o;
                    ^
pc.h:13:20: error: template argument 1 is invalid
pc.h:13:9: error: template argument 1 is invalid
  sc_out<sc_bv<12>> pc_o;

Note: Beggining SystemC-2.3.2 release now it is mandatory to provide the C++ compiler standard flag for compiling the SystemC model code.

// Command Executed
////////////////////////////////////////////
// Notice the -std=c++11 compiler flag.
// $ g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib -Wl,-rpath=$SYSTEMC_HOME/lib -std=c++11 -o hello pc.h -lsystemc -lm
/home/ameya/apps/systemc-2.3.2/lib/libsystemc.so: undefined reference to `sc_main'
collect2: error: ld returned 1 exit status

If you need some demo example on how to use the CMake for building SystemC project you can look into the SystemC examples folder or for much simple example here.

 

Let me know if this helps.

Regards,

Ameya Vikram Singh

Edited by AmeyaVS
updated the code example output.
Link to comment
Share on other sites

21 hours ago, AmeyaVS said:

Hello @Edward1110,

Firstly why are you trying to compile a header file with missing definition of the method "pc_main".

Can you post the exact error log that you get from the console output while running the command?(Use the code block to post the console output.)

Here is the output from the command on my system:(Kindly Note I am using CMake to build the SystemC library.)


// Command executed:
// $ g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib -Wl,-rpath=$SYSTEMC_HOME/lib -o hello pc.h -lsystemc -lm

pc.h:10:19: error: jump_addr was not declared in this scope
  sc_in<sc_lv<12>> jump_addr;
                   ^
pc.h:10:19: error: template argument 1 is invalid
pc.h:10:8: error: template argument 1 is invalid
  sc_in<sc_lv<12>> jump_addr;
        ^
pc.h:11:19: error: branch_length was not declared in this scope
  sc_in<sc_bv<12>> branch_length;
                   ^
pc.h:11:19: error: template argument 1 is invalid
pc.h:11:8: error: template argument 1 is invalid
  sc_in<sc_bv<12>> branch_length;
        ^
pc.h:13:20: error: pc_o was not declared in this scope
  sc_out<sc_bv<12>> pc_o;
                    ^
pc.h:13:20: error: template argument 1 is invalid
pc.h:13:9: error: template argument 1 is invalid
  sc_out<sc_bv<12>> pc_o;

Note: Beggining SystemC-2.3.2 release now it is mandatory to provide the C++ compiler standard flag for compiling the SystemC model code.


// Command Executed
////////////////////////////////////////////
// Notice the -std=c++11 compiler flag.
// $ g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib -Wl,-rpath=$SYSTEMC_HOME/lib -std=c++11 -o hello pc.h -lsystemc -lm
/home/ameya/apps/systemc-2.3.2/lib/libsystemc.so: undefined reference to `sc_main'
collect2: error: ld returned 1 exit status

If you need some demo example on how to use the CMake for building SystemC project you can look into the SystemC examples folder or for much simple example here.

 

Let me know if this helps.

Regards,

Ameya Vikram Singh

 

 

Dear Ameya,

Thank you for your answer

I don't know how to run systemc code on codeblcok, so I didn't get the console output, but I am trying to work it out.

I used my pc.cpp file this time, which I put into attachment

I tried you command

g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=$SYSTEMC_HOME/lib-linux64 -std=c++11 -o hello pc.cpp -lsystemc -lm/home/usr/local/systemc-2.3.2/lib-linux64/libsystemc.so

The output is

/usr/bin/ld: cannot find -lm/home/usr/local/systemc-2.3.2/lib-linux64/libsystemc.so
collect2: error: ld returned 1 exit status

But I tried this command

g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=$SYSTEMC_HOME/lib-linux64 -std=c++11 -o hello pc.cpp -lsystemc -lm

/tmp/ccfTt0wt.o: In function `__static_initialization_and_destruction_0(int, int)':
pc.cpp:(.text+0xd60): undefined reference to `sc_core::sc_api_version_2_3_2_cxx201103L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx201103L(sc_core::sc_writer_policy)'
collect2: error: ld returned 1 exit status

and there is still no output file.

 

 

pc.cpp

Link to comment
Share on other sites

40 minutes ago, Edward1110 said:

[...]

But I tried this command

g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=$SYSTEMC_HOME/lib-linux64 -std=c++11 -o hello pc.cpp -lsystemc -lm

/tmp/ccfTt0wt.o: In function `__static_initialization_and_destruction_0(int, int)':
pc.cpp:(.text+0xd60): undefined reference to `sc_core::sc_api_version_2_3_2_cxx201103L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx201103L(sc_core::sc_writer_policy)'
collect2: error: ld returned 1 exit status

and there is still no output file.

[...]

This error message suggests that SystemC itself was not built with the C++'11 standard enabled. Please follow the INSTALL instructions in the SystemC 2.3.2 PoC distribution archive (Section "Preprocessor switches" SC_CPLUSPLUS). The C++ language standard needs to be consistently defined for the SystemC library and your application. This is enforced by the sc_api_version_* linker symbol that you see in the error message.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...