How to use function implemented in asm from *.cpp file, in VisualDsp++ 5, for Blackfin BF537?

StackOverflow https://stackoverflow.com/questions/9045713

  •  20-04-2021
  •  | 
  •  

Question

I have this project explained in "Wiley-Embedded Signal Processing with the Micro Signal Architecture.2007" - 2D DCT/IDCT (image compression) implemented, and i want to combine (move these files to..) with another personal project with image processing (which have only *.cpp files) in Visual Dsp for Blackfin BF 537. (first in Simulator, and after that on the board BF537..)

The implemented project 2D DCT/IDCT has *.c and *.asm files and it works verry well. At some point, for some calculations, from C file is using a function declared (and implemented) in asm file.

I noticed that if i move these *.c files in my project (which contain only *.cpp files), i get lots of errors and some like this one:

"`[Error li1021] The following symbols referenced in processor 'p0' could not be resolved:
   'something [_something]' referenced from '.\Debug\project name.doj'"

So, i think i need to have just *.cpp files in my project (not combination off *.cpp and *.c).

In the 2D DCT/IDCT project, the problem appear when i'm changing all those *.c files to *.cpp files. When i'm trying to build, i get this linking error:

"[Error li1021]  The following symbols referenced in processor 'p0' could not be resolved:
   '_r8x8dct(short *, short *, short *) [__r8x8dct__FPsN21]' referenced from '.\Debug\Start_DCT2.doj'
   '_r8x8invdct_ieee(short *, short *, short *) [__r8x8invdct_ieee__FPsN21]' referenced from '.\Debug\Start_DCT2.doj'"

In *.cpp file this is how i'm calling the function implemented in asm:

     _r8x8dct(in,coeff,temp);

In the same *.cpp file i include a header file where i declared the function:

     void _r8x8dct(fract16 *in, fract16 *coeff, fract16 *temp);

And here is part of the *.asm file which contain the function:

     .section    L1_code;
     .global     __r8x8dct;
     .align      8;
     __r8x8dct:
     .....................................
     __r8x8dct.end:

Analog with function $_r8x8invdct_ieee()

*please excuse me for my english writing errors

Was it helpful?

Solution

To call C functions from C++ you need to qualify the C function prototypes with extern "C", e.g.

extern "C" void _r8x8dct(fract16 *in, fract16 *coeff, fract16 *temp);

or if you have more than one C function you can group the prototypes together like this:

extern "C" {

    void _r8x8dct(fract16 *in, fract16 *coeff, fract16 *temp);

    // ... other C function prototypes ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top