I am currently working on a JNI Project where the C part uses local libraries on my NanoPi. Construction of Headers, Implementing it in C and Testing the Wrapper worked fine. Now I tried to add shared library support to my make file and I can't get it to run. Unfortunately I am new to Makefiles and couldn't find a tutorial so far which explains all my needs in detail so I can fix it by myself.
Below you can find the Makefile I constructed so far and which was used for testing the implementation.
DYN_VERS_MAJ=2
DYN_VERS_MIN=0
VERSION=$(DYN_VERS_MAJ).$(DYN_VERS_MIN)
DEBUG = -O3
CC = gcc
INCLUDE = -I/usr/local/include -I/usr/lib/jvm/java-1.8.0-openjdk-
armhf/include -I/usr/lib/jvm/java-1.8.0-openjdk-armhf/include/linux
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe -fPIC -Wformat=2
LDFLAGS = -L/usr/local/lib
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm -lwiringPiPca9685
SRC = pwm_native_PCA9685Native.c
DYNAMIC=libPca9685Native.so.$(VERSION)
OBJ = $(SRC:.c=.o)
BINS =$(SRC:.c=)
all: $(DYNAMIC)
$(Dynamic): $(OBJ)
@echo "[Link (Dynamic)]"
@$(CC) -shared -Wl,-soname,libPca9685Native.so -o libPca9685Native.so.$(VERSION) -lpthread $(OBJ)
driver: pwm_native_PCA9685Native.o
@echo [link]
@$(CC) -o $@ pwm_native_PCA9685Native.o $(LDFLAGS) $(LDLIBS)
.c.o:
@echo [Compile] $<
@$(CC) -c $(CFLAGS) $< -o $@
clean:
@echo "[Clean]"
@rm -f $(OBJ) *~ core tags $(BINS)
tags: $(SRC)
@echo[ctags]
@ctags $(SRC)
depend:
makedepend -Y $(SRC)
The (Dynamic) part is the new added part. All the time I try to run I get the message make: No rule to make target 'libPca9685Native.so.2.0', needed by all. The output is clear to me. A rule is missing to create the so file but I don't know how to add that rule... Help would be really appreciated. Regards Peter
Here:
all: $(DYNAMIC)
$(Dynamic): $(OBJ)
Makefile variables are case sensitive (even with MinGW gnu make on Windows). So you have to respect casing else $(Dynamic) isn't evaluated properly. Fix:
all: $(DYNAMIC)
$(DYNAMIC): $(OBJ)
(there may be other issues in your makefile, mind)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With