chipKIT® Development Platform

Inspired by Arduino™

How to link libXXX.a in platforms.txt

Created Thu, 31 Jan 2013 10:49:01 +0000 by kyab212


kyab212

Thu, 31 Jan 2013 10:49:01 +0000

I have libFoo.a and want to link with my sketch. But how can I do ?

I've tried to add library path to pic32.library.path and specify -lFoo in pic32.compiler.c.elf.flags in platforms.txt, but It does not work.

any advice?


kyab212

Fri, 01 Feb 2013 15:52:19 +0000

I solved by myself.

At first, in my case libfoo.a was compiled as C(not C++), so I should include with extern "C" in my sketch.

extern "C"{
 #include "foo.h"
}

then, in platforms.txt, I changed as below lines.

pic32.recipe.c.combine.pattern={0}{1}::{2}::{3}{4}::-o::{5}{6}.elf::{7}::{8}::-L/dir/of/libfoo/lib::-lfoo::-L{9}::-lm::-T::{10}/{11}
pic32.compiler.cpp.flags=-O2::-c::-mno-smart-io::-w::-fno-exceptions::-ffunction-sections::-fdata-sections::-g::-mdebugger::-Wcast-align::-fno-short-double::-I/dir/of/libfoo/include

libfoo.a is located on /dir/of/libfoo/lib and headers are located on /dir/of/libfoo/include.

After reboot MPIDE, I succeeded to build my sketch!