Log in

View Full Version : Calling C functions from EasyC


koenig3456
27-01-2006, 11:07
I've written some functions in C using MPLab. The modules include both static data and code. How can I use them in an EasyC project?

dcbrown
27-01-2006, 11:23
I've written some functions in C using MPLab. The modules include both static data and code. How can I use them in an EasyC project?

I think the answer is wait for next version of EasyC. See thread EasyC Wish List (http://www.chiefdelphi.com/forums/showthread.php?t=42497), esp. reply #4.

Regards,
DCBrown

koenig3456
27-01-2006, 13:27
Thanks for the hint.
I may have figured out a solution. I don't have access to the RC right now, so I can't test it. It does compile and link successfully.

This is what I did:
1. Compile the C code using MPLab.
2. Use mplib.exe to add the .o file to the wpilib.lib in the EasyC folder.
3. Add the header file to EasyC (Options/File Inclusion).

dcbrown
27-01-2006, 15:09
Clever. I hadn't thought about adding additional .o files to the default library. To use to environments where libraries are protected except for read access.

We have a need for something similar, can't wait to try it.

Regards,
DCBrown

dcbrown
27-01-2006, 16:03
Tried something similar just now...

1. Use MPLab to create .o object files
2. Use command window, use mplib to create .lib file (mplib /c MyTest.lib)
3. Add .o files to my library (mplib /r MyTest.lib MyTest.o)
3. move a copy of my library MyTest.lib to c:\mcc18\lib so it can be found by EasyC during link time
4. update <processor>.lkr file under EasyC in Frc\18F***\ to reference my library, e.g.

:
FILES clib.lib
FILES p18f8520.lib
FILES MyTest.lib << added this
:

5. Referenced functions/data in MyTest.lib in EasyC... compiled/linked correctly.

Regards,
DCBrown