Junos Developer
Announcement This site is read-only until Nov. 18
Questions? Read our FAQ and blog.
Highlighted
Junos Developer

How to add libraries into Junos SDK application?

‎03-11-2010 12:37 PM

How can I add my library or port some 3rd party libraries into Junos SDK application?

 

1 REPLY 1
Highlighted
Junos Developer

Re: How to add libraries into Junos SDK application?

‎03-11-2010 01:01 PM

Here are the steps to add user or 3rd party libraries into Junos SDK application.

'foo' is the example library name. $SB is the path of developer's sandbox.

 

1. Make Directories

 

The library code, header files, Makefiles, etc. need to be located in $SB/src/lib/libfoo directory.

 

For porting 3rd party libraries, it recommended to put code into $SB/src/contrib/foo directory.

 

2. Build Makefile

 

Here is an example of library Makefile.

--------------------------------

LIB = foo

 

SHLIB_MAJOR = 1
SHLIB_MINOR = 0

 

FOO_src=${SRCTOP}/lib/libfoo

 

.PATH: ${FOO_SRC}
SRCS = foo1.c foo2.c

 

CFLAGS += -I${.CURDIR}

 

SRC_LIBS += ${LIBM}

 

.include <bsd.lib.mk>

--------------------------------

 

3. Define Library

 

The library name, header file directory and dependencies are defined in $SB/src/build/mk/libnames.mk.

 

LIBFOO = ${OBJTOP}/lib/libfoo/libfoo.a
INCLUDES_libfoo = -I${SRCTOP}/lib/libfoo/include

DPLIBS_libfoo = ${LIBM}

 

4. Build Library

 

The following two command will build library for i386, XLR and octeon respectively.

$SB/src/lib/libfoo/mk

$SB/src/lib/libfoo/mk-xlr

$SB/src/lib/libfoo/mk-octeon

 

Adding library into $SB/src/lib/Makefile will have library built when issue mk command in $SB/src/lib

or $SB/src directory.

 

5. Build Executable Binary with Library

 

To link library to the executable, the library needs to be added into DPLIBS in $SB/src/sbin/*/Makefile.

For using shared library, "-Wl,-rpath=${JUNOS_SDK_INSTALLDIR}/lib" also needs to be added into

CFLAGS to specifiy the path of shared library.


6. Add Library into Package

 

For using shared library, it needs to be added into the package so it will be installed onto the router.

This is done by updating the manifest file.

 

 

Feedback