Ifgen tool : simple IPC api

Hi, I’m trying to use the legacy sample app and include “interfaces.h” in my source codes to use the legato ipc apis. To do that,I created two separate apps following a little bit the helloIpc samples, but I can’t compile with mktools it tells that there is undefined reference to_printServer_COMPONENT_INIT’`. I think that my source code which has a separate main loop causes that. So, my solution was to not use the mkapp and use make with the toolchain and combine with ifgen to generate sources and headers from the .api but this, does not generate the interfaces.h. How can I generate this file with only ifgen?

Thank you

I don’t know if there is a best way to do this but now, I used the --gen-all option and included manually the files generated from .api. When compiling my server side adef I get this message : error: Executable 'appserver' not defined in application this is my app server adef file :

sandboxed: false

bundles:
{file: { [x] appserver /bin/ }}

processes:
{ run: { ( appserver ) }}

extern:
{ printer = appserver.appserver.printer }

the appserver file is cross compiled using the toolchain. The error I got is searching for a sources section in the adef but this section don’t work for me. So I’m guessing that I have to change my extern section but I don’t know how. Can you tell what changes I have to do to make this work ?

Ok, I changed my server side adef file extern section to :

extern:
{
provides:
{
printer= printer.api
}
}

and in the client side :

extern:
{
requires:
{
printer= printer.api }
}

in my sdef I added this :

bindings:
{
appclient.printer-> appserver.printer
}

When compiling I have this error :

No such external server-side interface ‘printer’ on app ‘appserver’.

Hi,

Can you compile the sample helloIPC application with Developer Studio first?
It should be working fine.

After that you can use terminal to build it with mkapp command and “-v” parameter to see how ifgen is used.
Please see below:


owner@ubuntu:~/workspace_mangoH/helloIPC$ mkapp -t ar7 -o Target_Legato_Debug -w Target_Legato_Debug -i “/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/positioning” -i “/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces” -i “/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/secureStorage” -i “/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/logDaemon” -i “/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/modemServices” -i “/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/airVantage” -i “/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/supervisor” -s “.” -C -g -X -g -L -g helloIPC.adef -v
Command-line arguments from previous run not found.
Parsing file: ‘/home/owner/workspace_mangoH/helloIPC/helloIPC.adef’.
Modelling application: 'helloIPC’
defined in: '/home/owner/workspace_mangoH/helloIPC/helloIPC.adef’
Application ‘helloIPC’ contains executable ‘server’.
Parsing file: ‘/home/owner/workspace_mangoH/helloIPC/printServer/Component.cdef’.
Modelling component: 'printServer’
found at: ‘/home/owner/workspace_mangoH/helloIPC/printServer’
== ‘printServer’ component summary ==
Component library: ‘Target_Legato_Debug/staging/read-only/lib/libComponent_printServer.so’
C sources:
’/home/owner/workspace_mangoH/helloIPC/printServer/server.c’
IPC API server-side interfaces:
‘printer’:
API defined in: '/home/owner/workspace_mangoH/helloIPC/printer.api’
Executable ‘server’ in application ‘helloIPC’ contains component ‘printServer’ (/home/owner/workspace_mangoH/helloIPC/printServer).

== ‘helloIPC’ application summary ==

Uses components:
'printServer’
Builds executables:
'server’
Instantiates components:
'printServer’
Runs inside a sandbox.
Has the following limits:
maxSecureStorageBytes: 8192
maxThreads: 20
maxMQueueBytes: 512
maxQueuedSignals: 100
maxMemoryBytes: 40960000
cpuShare: 1024
maxFileSystemBytes: 524288
Has access to the following configuration trees:
Its own tree: read + write
Will be started automatically when the Legato framework starts.
When started, will run process: 'server’
Executing file: 'server’
Without any command line arguments.
With the following environment variables:
PATH=/usr/local/bin:/usr/bin:/bin
Fault recovery action: ignore (default)
Watchdog timeout: disabled
With the following limits:
Max. core dump file size: 524288 bytes
Max. file size: 524288 bytes
Max. locked memory size: 8192 bytes
Max. number of file descriptors: 256
Executable ‘server’:
Serves the following IPC API interfaces:
'printer’
API defined in: ‘/home/owner/workspace_mangoH/helloIPC/printer.api’

Generating system configuration data for app ‘helloIPC’ in file ‘Target_Legato_Debug/app/helloIPC/staging/root.cfg’.
Generating startup code for executable ‘server’ (app/helloIPC/staging/read-only/bin/server) in ‘Target_Legato_Debug/app/helloIPC/src/server/_main.c’.
Generating Air Vantage manifest: Target_Legato_Debug/app/helloIPC/manifest.app
Generating interfaces.h for component 'printServer’in ‘Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/src/interfaces.h’.
Generating component-specific IPC code for component ‘printServer’ in ‘Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/src/_componentMain.c’.
Generating ninja build script: ‘Target_Legato_Debug/build.ninja’.
Executing ninja build system…
$ ninja -v -d explain -f Target_Legato_Debug/build.ninja
ninja explain: depfile ‘Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/obj/3cc0e00f13872a6ba90332e16b3e34e4.o.d’ is missing
ninja explain: output Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server/printer_server.c doesn’t exist
ninja explain: Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/obj/3cc0e00f13872a6ba90332e16b3e34e4.o is dirty
ninja explain: depfile ‘Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server/printer_server.o.d’ is missing
ninja explain: Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server/printer_server.c is dirty
ninja explain: Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server/printer_messages.h is dirty
ninja explain: Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server/printer_server.h is dirty
ninja explain: Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server/printer_server.o is dirty
ninja explain: depfile ‘Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/obj/_componentMain.c.o.d’ is missing
ninja explain: Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/obj/_componentMain.c.o is dirty
ninja explain: Target_Legato_Debug/staging/read-only/lib/libComponent_printServer.so is dirty
ninja explain: Target_Legato_Debug/app/helloIPC/staging/read-only/lib/libComponent_printServer.so is dirty
ninja explain: depfile ‘Target_Legato_Debug/app/helloIPC/obj/server/_main.c.o.d’ is missing
ninja explain: Target_Legato_Debug/app/helloIPC/obj/server/_main.c.o is dirty
ninja explain: Target_Legato_Debug/staging/read-only/lib/libComponent_printServer.so is dirty
ninja explain: Target_Legato_Debug/app/helloIPC/staging/read-only/bin/server is dirty
ninja explain: Target_Legato_Debug/app/helloIPC/staging/info.properties is dirty
[1/10] /opt/swi/y16-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/y16-ext/sysroots/armv7a-vfp-neon-poky-linux-gnueabi -MMD -MF Target_Legato_Debug/app/helloIPC/obj/server/_main.c.o.d -c Target_Legato_Debug/app/helloIPC/src/server/_main.c -o Target_Legato_Debug/app/helloIPC/obj/server/_main.c.o -Wall -fPIC -Werror -fvisibility=hidden -DMK_TOOLS_BUILD -DLEGATO_EMBEDDED -g -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/framework/c/inc -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/positioning -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/secureStorage -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/logDaemon -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/modemServices -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/airVantage -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/supervisor -I/home/owner/workspace_mangoH/helloIPC -DLE_COMPONENT_NAME=server_exe -DLE_LOG_SESSION=server_exe_LogSession -DLE_LOG_LEVEL_FILTER_PTR=server_exe_LogLevelFilterPtr
[2/10] /opt/swi/y16-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/y16-ext/sysroots/armv7a-vfp-neon-poky-linux-gnueabi -MMD -MF Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/obj/_componentMain.c.o.d -c Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/src/_componentMain.c -o Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/obj/_componentMain.c.o -Wall -fPIC -Werror -fvisibility=hidden -DMK_TOOLS_BUILD -DLEGATO_EMBEDDED -g -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/framework/c/inc -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/positioning -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/secureStorage -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/logDaemon -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/modemServices -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/airVantage -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/supervisor -I/home/owner/workspace_mangoH/helloIPC -ITarget_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/src -ITarget_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server -DLE_COMPONENT_NAME=printServer -DLE_LOG_SESSION=printServer_LogSession -DLE_LOG_LEVEL_FILTER_PTR=printServer_LogLevelFilterPtr “-DCOMPONENT_INIT=LE_CI_LINKAGE LE_SHARED void _printServer_COMPONENT_INIT()”
[3/10] mkdir -p Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server && ifgen --output-dir Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server --gen-server --gen-server-interface --gen-local --name-prefix printer --file-prefix printer --import-dir /home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces --import-dir /home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/framework/c/inc --import-dir /home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/positioning --import-dir /home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces --import-dir /home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/secureStorage --import-dir /home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/logDaemon --import-dir /home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/modemServices --import-dir /home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/airVantage --import-dir /home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/supervisor --import-dir /home/owner/workspace_mangoH/helloIPC /home/owner/workspace_mangoH/helloIPC/printer.api
[4/10] /opt/swi/y16-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/y16-ext/sysroots/armv7a-vfp-neon-poky-linux-gnueabi -MMD -MF Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/obj/3cc0e00f13872a6ba90332e16b3e34e4.o.d -c /home/owner/workspace_mangoH/helloIPC/printServer/server.c -o Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/obj/3cc0e00f13872a6ba90332e16b3e34e4.o -Wall -fPIC -Werror -fvisibility=hidden -DMK_TOOLS_BUILD -DLEGATO_EMBEDDED -g -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/framework/c/inc -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/positioning -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/secureStorage -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/logDaemon -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/modemServices -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/airVantage -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/supervisor -I/home/owner/workspace_mangoH/helloIPC -ITarget_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/src -ITarget_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server -DLE_COMPONENT_NAME=printServer -DLE_LOG_SESSION=printServer_LogSession -DLE_LOG_LEVEL_FILTER_PTR=printServer_LogLevelFilterPtr “-DCOMPONENT_INIT=LE_CI_LINKAGE LE_SHARED void _printServer_COMPONENT_INIT()”
[5/10] /opt/swi/y16-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/y16-ext/sysroots/armv7a-vfp-neon-poky-linux-gnueabi -MMD -MF Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server/printer_server.o.d -c Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server/printer_server.c -o Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server/printer_server.o -Wall -fPIC -Werror -fvisibility=hidden -DMK_TOOLS_BUILD -DLEGATO_EMBEDDED -g -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/framework/c/inc -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/positioning -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/secureStorage -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/logDaemon -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/modemServices -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/airVantage -I/home/owner/legato/packages/legato.framework.16.1.4.m1/resources/legato/interfaces/supervisor -I/home/owner/workspace_mangoH/helloIPC
[6/10] /opt/swi/y16-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/y16-ext/sysroots/armv7a-vfp-neon-poky-linux-gnueabi -shared -o Target_Legato_Debug/staging/read-only/lib/libComponent_printServer.so Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/obj/3cc0e00f13872a6ba90332e16b3e34e4.o Target_Legato_Debug/api/cb090e5f4720b506cebb72af54f70a52/server/printer_server.o Target_Legato_Debug/component/ed8c27193cd420fb36cddde830769e1a/obj/_componentMain.c.o -LTarget_Legato_Debug/staging/read-only/lib -Wl,–enable-new-dtags,-rpath="$ORIGIN/…/lib" “-L$LEGATO_BUILD/framework/lib” -llegato -lpthread -lrt -lm
[7/10] ln -T -f Target_Legato_Debug/staging/read-only/lib/libComponent_printServer.so Target_Legato_Debug/app/helloIPC/staging/read-only/lib/libComponent_printServer.so
[8/10] /opt/swi/y16-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/y16-ext/sysroots/armv7a-vfp-neon-poky-linux-gnueabi -o Target_Legato_Debug/app/helloIPC/staging/read-only/bin/server Target_Legato_Debug/app/helloIPC/obj/server/_main.c.o -rdynamic -Wl,–enable-new-dtags,-rpath="$ORIGIN/…/lib" -LTarget_Legato_Debug/staging/read-only/lib “-LTarget_Legato_Debug/staging/read-only/lib” -lComponent_printServer “-LTarget_Legato_Debug/staging/read-only/lib” -lComponent_printServer “-L$LEGATO_BUILD/framework/lib” -llegato -lpthread -lrt -ldl -lm -g
[9/10] rm -f Target_Legato_Debug/app/helloIPC/staging/info.properties && md5=( ( find -P Target_Legato_Debug/app/helloIPC/staging | sort && find -P Target_Legato_Debug/app/helloIPC/staging -type f | sort | xargs cat && find -P Target_Legato_Debug/app/helloIPC/staging -type l | sort | xargs -r -n 1 readlink ) | md5sum) && md5={md5%% *} && ( echo “app.name=helloIPC” && echo “app.md5=$md5” && echo “app.version=1.0.0” && echo “legato.version=cat $LEGATO_ROOT/version” ) > Target_Legato_Debug/app/helloIPC/staging/info.properties
[10/10] tar cjf Target_Legato_Debug/app/helloIPC/helloIPC.ar7 -C Target_Legato_Debug/app/helloIPC/staging . && tarballSize=stat -c '%s' Target_Legato_Debug/app/helloIPC/helloIPC.ar7 && md5=grep '^app.md5=' Target_Legato_Debug/app/helloIPC/staging/info.properties | sed 's/^app.md5=//' && ( printf ‘{\n’ && printf ‘“command”:“updateApp”,\n’ && printf ‘“name”:“helloIPC”,\n’ && printf ‘“version”:“1.0.0”,\n’ && printf ‘“md5”:"%s",\n’ “$md5” && printf ‘“size”:%s\n’ "tarballSize" && printf '}' && cat Target_Legato_Debug/app/helloIPC/helloIPC.ar7 ) > Target_Legato_Debug/helloIPC.ar7.update owner@ubuntu:~/workspace_mangoH/helloIPC