making my own libraries or 3rd party libraries

Discussion to talk about software related topics only.
Post Reply
jpelletier
Posts: 18
Joined: Wed Dec 23, 2020 3:32 am

making my own libraries or 3rd party libraries

Post by jpelletier »

I'm trying to port the mcurses library from Arduino to NetBurner. With the makefile below, it compiles all the netburner code, not just this library.
I would like to use the boilerplate.mk for convenience, but how to do it to compile only my library?

My makefile contains:
NAME = mcurses

C_SRC = mcurses.c editor.c hexedit.c

include $(NNDK_ROOT)/make/boilerplate.mk

all:
$(CXX) -c mcurses.c -o mcurses.o
$(CXX) -c editor.c -o mcurses.o
$(CXX) -c hexedit.c -o mcurses.o
$(AR) -o mcurses.a mcurses.o editor.o hexedit.o

install:
cp mcurses.a ../lib
cp *.h ../include
User avatar
Forrest
Posts: 287
Joined: Wed Apr 23, 2008 10:05 am

Re: making my own libraries or 3rd party libraries

Post by Forrest »

Hello,

In your project makefile, you are going to want to set the variable TARGET_TYPE to a library. You have 3 different options for TARGET_TYPE:

Code: Select all

# Set TARGET_TYPE in your makefile to generate a target.
# Supported makefile target types: (default = app)
#	nblib	: build .a file and place in nburn lib directory
#	lib		: build .a file and place in current build directory
#	app		: build an _APP.s19 file and place in current directory
By default, app is selected. You will use nblib or lib, depending on your preference.

After you build the library, in your project that utilizes the library, you will add the following to your project makefile

XTRALIB += <libname>
Forrest Stanley
Project Engineer
NetBurner, Inc

NetBurner Learn Articles: http://www.netburner.com/learn
jpelletier
Posts: 18
Joined: Wed Dec 23, 2020 3:32 am

Re: making my own libraries or 3rd party libraries

Post by jpelletier »

Forrest wrote: Mon Mar 01, 2021 9:37 am Hello,

In your project makefile, you are going to want to set the variable TARGET_TYPE to a library. You have 3 different options for TARGET_TYPE:

Code: Select all

# Set TARGET_TYPE in your makefile to generate a target.
# Supported makefile target types: (default = app)
#	nblib	: build .a file and place in nburn lib directory
#	lib		: build .a file and place in current build directory
#	app		: build an _APP.s19 file and place in current directory
By default, app is selected. You will use nblib or lib, depending on your preference.

After you build the library, in your project that utilizes the library, you will add the following to your project makefile

XTRALIB += <libname>
Thanks, it worked fine!

Here's my updated makefile:
TARGET_TYPE = lib
NAME = mcurses

C_SRC = mcurses.c editor.c hexedit.c

include $(NNDK_ROOT)/make/boilerplate.mk

install:
cp obj/release/mcurses.a ../lib
cp *.h ../include
Sterling Johnson
Posts: 1
Joined: Fri Mar 05, 2021 11:50 am

Re: making my own libraries or 3rd party libraries

Post by Sterling Johnson »

Thank you for such a valuable information. It is very important for me.
Post Reply