Forum > Embedded

using a pascal library in my ARM embedded c project


Hi fellows,
we got a PC pascal library, several thousand lines of code, which does a bunch of calculations, and we would like to use it in our c embedded ARM project ( cortex m7, no OS involved).
Can somebody give us a hint if it's recommendable to somehow use freepascal to compile the pascal sources and use them by the c project ( compiled by gcc)?
It would be simply fantastic if this would work out!

I suppose of you were to compile all of that into a DLL,SO etc,.  you could link it in...

Just make sure you specify a calling standard on the exported functions.

Recommendable ? .. that depends. Is it a "dll" library or a "unit" library ? (confusion of the word library in this context is possible).

In case the latter then you could perhaps have some work for you to do (as mentioned by jamie). Some types don't really mix between c and pascal, and your functions would have to be exported.

Other than that, yes in theory it is possible. A matter of how much time you would like to invest.

Some links here, and here, and i found this, this and this (not sure if the last ones are able to help though).

Just try some simple tests first and in case of issues, search/ask for help. It goes without saying that things like intel assembler code (assuming your unit was written for a platform like windows) does not compile for arm target (in case you have asm optimized functionality in your unit).

there are two question to be answered here
1) does your c compiler support embedded assembly or not if yes then you could instruct FPC to export the assembly for the library and use that.
2) does the fpc chain support the obj format that your linker requires? if yes it might be easier to link against existing obj instead of the assembly as long as the fpc supports your embedded device.

In your position I would simple export the assembly and link it to my code it is more universal than trying to create and link binary libraries on a target that might not be supported by one of the compilers.

There is always a 3rd option, since you do not have any OS to help you, you could use the dll loader from WINE, but that will impose the same restrictions as the 2nd solution above, ee both compilers must support your embedded target


[0] Message Index

Go to full version