Fractal | Fractal ADL | Cecilia Examples | Minus
 

Usage

How do I link my Cecilia application with external libraries?

In the case where your are wrapping legacy C code inside your component functional code, you might need to add linking flags to external libraries.

With the ceciliac command line, add a ld-flags parameter:

$ ceciliac -ld-flags="-lTHE_LIBRARY_NAME" ...

With Maven : Add the library in a ld-flags parameter in the maven-ceciliaadl-plugin configuration section.

<plugin>
  <groupId>org.objectweb.fractal.cecilia.toolchain</groupId>
  <artifactId>maven-ceciliaadl-plugin</artifactId>
  <version>...</version>
  <configuration>
    ...
    <arguments>
      ...
      <parameter>
        <name>ld-flags</name>
        <value>-lTHE_LIBRARY_NAME</value>
      </parameter>
      ...
    </arguments>
  </configuration>
</plugin>
[top]

How do I use plain C source files in a Cecilia application ?

This can be achieve using the include ADL element. This element allows to specify additional C source file as part of the component implementation.

<definition>
  ...
  <content>
    <include></include>
    <include></include>
    ...
  </content>
  ...
</definition>

The included files will be compiled and linked with the rest of the application, so global symbols defined in these C files can be referenced by other C files in the application. Note that this can actually break the Fractal model if another component references these symbol since this will lead to an hidden communication channel between two different components.

This technique can be used to build library components (i.e. a component that provides a set of C function to other components). As mentioned above, that kind of component break the Fractal model, but in some circumstances, this can be very useful (for instance to provide a 'libc' component in a micro-kernel)

A library components is a component that has no interface (neither client nor server) and that has no private data. That kind of component only contains pure C code.

For instance:

<definition>
  <content>
    <include></include>
    <include></include>
    <include></include>
    ...
  </content>
</definition>

Where libc/LibCEmptyData.c looks like:

/** Declare component internal data (empty) */
DECLARE_DATA {
  // no data
};

/** Include cecilia.h. Must be included after the DECLARE_DATA */
#include "cecilia.h"
[top]

How can I retarget the ADL toolchain for cross-compilation of my Cecilia application ?

Multiple parameters of the cecilia compiler can be used to specify a non-default compiler, linker, library path, etc.

  • compiler-command (shortcut: cc ): allows to specify the path to the C compiler to be used;
  • linker-command (shortcut: ld ): allows to specify the path to the linker to be used;
  • linker-script (shortcut: T ): allows to specify the path to the linker script. The linker script file is searched in the cecilia compile source path.

More parameters are available, for a complete list see the User guide

[top]

Troubleshooting compiler/linker errors

Why C compiler/linker is reporting obscure errors

When the Cecilia compiler is run, it parses and checks ADL and IDL files, generates C source code according to these input files and execute the C compiler/linker. But the Cecilia compiler is not able to check if the implementation C source code is coherent with the ADL or the IDL (missing implementation of a method, reference to an invalid client interface, wrong method prototypes, ...). So the Cecilia compiler is not able to report a clear messages for that kind of errors. Most of them will be detected by the C compiler or linker and reported with a more or less obscure message. Next Questions/Answers should help you to make light of these messages.

[top]

error: 'struct ..._importeds' has no member named '[itf_name]'

Most of the time, this error means that the implementation code is trying to access to a client interface that does not exist.

The location of the error, reported by GCC should helps you to locate the error. The error should consist of usage of the REQUIRED macro followed by a name that does not correspond to a client interface declared in the ADL of the component.

[top]

In file included from [file.c], .../cecilia.h:...: error: field 'data' has incomplete type
This is because file.c is missing the declaration of component internal data, or because cecilia.h has been included before the declaration of component internal data. Your implementation file must starts with:
DECLARE_DATA {
  ...
};

// Must be included after DECLARE_DATA.
#include "cecilia.h"
[top]

error: conflicting types for ... previous declaration of ... was here

When Gcc reports an error that looks like:

In file included from .../[ADLname_comp1_comp2...].adl.c:[line]:
.../[file.c]:[line]: error: conflicting types for '[ADLname_comp1_comp2...]_[itfname]_[methodname]_method'
.../[ADLname_comp1_comp2...].adl.c:[line]: error:
  previous declaration of '[ADLname_comp1_comp2...]_[itfname]_[methodname]_method' was here

This indicates a mismatch between the definition of a method in the IDL and the definition of the method in the C code. Check the IDL and C declarations. The guidelines for translating IDL to C are described in this page . Don't forget to add void * _this as the first argument of the C declaration (only on those methods exported to other components), but don't add it on the IDL declaration.

[top]

.../[ADLname_comp1_comp2...].adl.c:[line]: warning: missing initializer

When Gcc reports an error that looks like:

.../[ADLname_comp1_comp2...].adl.c:[line]: warning: missing initializer
.../[ADLname_comp1_comp2...].adl.c:[line]: warning: (near initialization for 
  '[ADLname_comp1_comp2...]_.data')

This happens when non-empty DECLARE_DATA structures are declared and the warning level is high enough. When generating the code, the toolchain doesn't know how many elements this structure contains, and doesn't know what the elements' types are, because it does not parse the C source code. Therefore, it cannot generate any initializers for this structure, and that's what the compiler is complaining about.

You cannot fix this warning, but under GCC 4.0 and later, you can hide it using the -Wno-missing-field-initializers switch.

[top]
 
2007-2009 © ObjectWeb Consortium  | Last Published: 2009-04-21 13:29  | Version: 2.1.0