Forum > Embedded - ARM

using c libraries in embedded fpc project

(1/4) > >>

diego bertotti:
Hello
Someone use a c library in a embedded arm/avr fpc project?
I know it can be do it, using external cdecl.
I'll try, but i appreciate all the help you'll can bring me
thanks
diego

Ñuño_Martínez:
What problem do you have?

Anyway, read $L or $LINK : Link object file,  $LINKLIB : Link to a library and External functions.

Also note that not always you should use CDECL, sometimes you should use STDCALL.  It depends the way the function was declared and compiled in C.

JiaXing:

--- Quote from: Ñuño_Martínez on April 13, 2020, 12:34:04 pm ---What problem do you have?

Anyway, read $L or $LINK : Link object file,  $LINKLIB : Link to a library and External functions.

Also note that not always you should use CDECL, sometimes you should use STDCALL.  It depends the way the function was declared and compiled in C.

--- End quote ---

I didn't see anyone use STDCALL outside of the Windows world. It's all CDECL.

PascalDragon:

--- Quote from: Ñuño_Martínez on April 13, 2020, 12:34:04 pm ---Also note that not always you should use CDECL, sometimes you should use STDCALL.  It depends the way the function was declared and compiled in C.

--- End quote ---

On non-i386 targets that doesn't matter anyway as there is only one calling convention per target (in general; there are a few exceptions, but they are very rare).


--- Quote from: JiaXing on April 13, 2020, 01:14:34 pm ---I didn't see anyone use STDCALL outside of the Windows world. It's all CDECL.

--- End quote ---

It's very seldom, but GCC does support the other calling conventions for i386 after all.

diego bertotti:
hi.

i try to use this units from arduino example "HardTimerAsEncoder".

was complied using gcc c compiler (arduino ide)


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program project_ext_c_lib; //{$L HardwareTimer.o} uses cortexm3; {$O-}  Procedure HardwareTimer(ID: byte); cdecl; external;// name 'HardwareTimer';  {$L HardwareTimer.o}  Procedure pause; cdecl; external;// name 'pause';  {$L HardwareTimer.o}  Procedure attachInterrupt(pin: byte; handler: byte; mode: byte); cdecl;  external;  {$L ext_interrupts.o} begin  HardwareTimer(2);   pause;   attachInterrupt(0,0,0); //not real params values, just to test compiler/linker end.   
and the result was.....

Messages window
***************************
Compile Project, OS: embedded, CPU: arm, Target: project_ext_c_lib: Exit code 1, Errors: 1
C:\Users\user\Documents\lib\arm-embedded\project_ext_c_lib.o: In function `PASCALMAIN':
project_ext_c_lib.lpr:(.text.n_main+0x14): undefined reference to `HardwareTimer'
project_ext_c_lib.lpr:(.text.n_main+0x18): undefined reference to `pause'
project_ext_c_lib.lpr:(.text.n_main+0x28): undefined reference to `attachInterrupt'
project_ext_c_lib.lpr(25,0) Error: Error while linking
***************************

what i do wrong?

HardwareTimer.o and  ext_interrupts.o and its parents .h and .cpp files are in the same directory of project

lazarus 2.1.0 fpc 3.3.1 win 10

thanks

Navigation

[0] Message Index

[#] Next page

Go to full version