# Undefined reference to function form C classes

**URL:** <https://verificationacademy.com/forums/t/undefined-reference-to-function-form-c-classes/33088>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, System-Verilog, Systemverilog-DPI\
**Created:** [April 28, 2017, 8:23am UTC](https://verificationacademy.com/forums/t/undefined-reference-to-function-form-c-classes/33088 "2017-04-28T08:23:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sachin\_86](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@sachin\_86](https://verificationacademy.com/forums/u/sachin_86)\
**Post date:** [April 28, 2017, 8:23am UTC](https://verificationacademy.com/forums/t/undefined-reference-to-function-form-c-classes/33088/1 "2017-04-28T08:23:13Z")

</div>

Hi,  
I am getting Unresolved references to the function → do\_something() when integrated the C into SV env.  
Can anyone please help me figure out what the issue is.

below is how my env looks like:  
Cmodel class

```verilog
class model1{
   int a;
   void do_something{
    // Do the processing
   }
}

```

This is how my top CPP test looks like:

```verilog
#include model1.cpp
extern "C" {

   void do_pack(){
    // FUnction implementation
    }
   void do_unpack(){
    // FUnction implementation
   }
   void processing(){
     do_something();
    // FUnction implementation
   }
}

```

This is how my SV top looks like:

```verilog
module top;
  import "DPI" function void processing();
  DUT(.*)

  initial
  begin
  // input randomization;
  processing();
  // output parsing
  end

endmodule

```

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [April 28, 2017, 2:35pm UTC](https://verificationacademy.com/forums/t/undefined-reference-to-function-form-c-classes/33088/2 "2017-04-28T14:35:45Z")

</div>

_In reply to [sachinherkal](https://verificationacademy.com/forums/t/undefined-reference-to-function-form-c-classes/33088):_  
You need to make do\_something() a public method in your model1 class. Then you need to construct an instance of model1 in your C++ test file.

```auto
#include model1.cpp
extern "C" {
   model1 m;
   void do_pack(){
    // FUnction implementation
    }
   void do_unpack(){
    // FUnction implementation
   }
   void processing(){
     m.do_something();
    // FUnction implementation
   }
}

```
