Search code examples
cmakefilecontikimruby

Compile Contiki application with MRuby


I am trying to compile a Contiki application that includes MRuby libraries and executes some simple ruby code. The problem is, I don't know how to include the MRuby libraries in the compilation.

Here is the project: https://github.com/matus-tomlein/contiki-mruby-example/tree/wrong

The code I want to execute is in contiki-mruby-example.c. The problem is probably in the Makefile. This is what I have currently:

CONTIKI_PROJECT = contiki-mruby-example
all: $(CONTIKI_PROJECT)

CONTIKIDIRS += mruby/include

CFLAGS += -v
CFLAGS += -Imruby/include

CONTIKI = contiki
include $(CONTIKI)/Makefile.include

I get the following error when I execute make:

ld: can't map file, errno=22 file 'mruby/include' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The MRuby code I want to include is in mruby/include.

This is a similar question: How to use external libraries and compile them along with a Contiki application But using TARGET_LIBFILES or LDFLAGS didn't help. I guess that is because I am compiling plain source code, not libraries.

There probably is a simple answer that I am missing. Thanks for any suggestions.


Solution

  • Thanks @kfx for the comment, you were right that I should have linked the library in the Makefile.

    Just to help anyone else that might have this problem:

    1. Go to the mruby subfolder and execute make
    2. Add this to Makefile: TARGET_LIBFILES += mruby/build/host/lib/libmruby.a

    I have updated the example repo with the fix: https://github.com/matus-tomlein/contiki-mruby-example