Looks like the compiler cannot find run_classifier()
. Check this.
yes i have defined them in the compiler
in c standalone example , it do not seems to add any run_classifier included header file?
maybe i am misunderstood the page?
i saw conditions with C linkage but it comes with __cplusplus too.
my compiler and project is not C++.
if i define the __cplusplus too, it would pop up like few hundreds syntax error relate to c++
- Which compiler are you using?
- Does it fail during compilation (producing
main.o
) ? - or during linking with libedgeimpulse.so producing
edge-impulse-standalone
?
In main.c we forward declare run_classifier
so if it fails to produce main.o I would look at your compiler arguments/flags.
The definition of run_classifier is in libedgeimpulse.so
. Can you confirm whether building libedgeimpulse.so
was successful.
If it the shared library was built successfully, then the last step is to link the application with the shared libedgeimpulse.so. If this failed. I’d check whether you have the right linker flags to find the shared libedgeimpulse.so.
- Keil
- I want to deploy the whole thing into my project. so i am not producing the standalone-c main
and i just copy the standalone-c main code to my project and put those file in my project - i can’t see any libedgeimpulse.so file? how to produce it ? maybe i just need that to run my code?
Thanks
p.s
i found i can build libedgeimpulse.so in the standalone-c folder
i am trying to look if my simple regression is work or not
i put 5 values in the feature , seems there is one output only when i execute the .exe
maybe i put too many feature in that ? how to rebuild the whole thing?
the libedgeimpulse.so seems cannot be directly use on my project
when i build my project there are errors in the libedgeimpulse.so
If I understand correctly you’ve built the libedgeimpulse.so library in the C example standalone repo that @MMarcial referenced and tried to use this library in your own keil project?
If so, then this is not going to work. You have to build and link libedgeimpulse
using the same compiler you use in your Keil environment.
Take a look at this example of using GNU Toolchain and GNU Make:
- creating a static library: https://github.com/edgeimpulse/example-standalone-inferencing-with-library/blob/master/C/static/Makefile#L67
- linking that library with a C application: https://github.com/edgeimpulse/example-standalone-inferencing-with-library/blob/master/C/static/Makefile#L71
Change the flags, compiler, linker and archiver accordingly for your toolchain, target and host.
Can you share what output logs?
To rebuild with GNU make it’s make clean
followed by a make
.
i don’t understand how to build and link the libedgeimpulse in my project
do you have detail steps for this?
the second problem is solve . the standalone example works now
Thank you
You mention you’re using Arm Keil toolchain, so I assume and base on here that your compiler (CC) is armclang
, linker is armlink
and archiver (AR) is armar
.
To build a static libedgeimpulse.a for your target and toolchain try and using this repo.
- Go to
C/static/
directory - Edit Makefile’s
# Target Specific
section with target specific flags and load the right porting layer for your target. Don’t see your target in theedge_impulse_sdk/porting/*
? Then take a look at our Porting Guide. - In a console run:
make clean
- In a console run:
CC=armclang CXX=armclang AR=armar make
Note you may need to add target specific flags. More info here and here.
Once you have built the static library using arm keil toolchain you can then link against this to create your final applicaiton. This can be done with the compiler or with linker.
Hi @rjames
thanks for your help
but i don’t know if i need to add some target specific flags
is there a instruction for adding flags to corresponding device?
my device is cortex m3 and using ARM architecture v7-M
the line would be CFLAGS += -march=armv7-m ?
and the origin CFLAGS += -DTF_LITE_DISABLE_X86_NEON=1 should be removed?
i tried to make the lib by adding mbed porting
it seems looking for .o files
is it necessary ? cause i just want to get the lib file for my device to work with
or do i need to make a new project on keil to compile a library ? but how about the Makefile?
Yes you can buid the library alone with make build/libedgeimpulse.so
. Note that you are currently building a shared library for x86 and not a static library for Cortex-M3. Meaning you won’t be able to use the library on the Cortex-M3. Please take a look building static edgeimpulse library for C application repo. In this case to build only the library, use make build/libedgeimpulse.a
You need to specify Cortex-m3 target flags see below flags passed to GNU Arm Toolchain.
CFLAGS += -march=armv7-m
CFLAGS += -mcpu=cortex-m3
CFLAGS += -mthumb
Other flags you may want to consider:
CXXFLAGS += -fno-rtti
LDFLAGS += -specs=nano.specs -specs=nosys.specs
You need to specify equivalent (if not the same) flags for armclang
.
They’re more flags that may need to be provided, not too mention linker flags and linker files. etc.
Which evaluation/development kit or board are you using? I’d suggest to re-use flags, linker files, etc. used in their examples provided (or their IDE).
Hi @rjames ,
i am using a custom board of this series of chip
https://www.sonix.com.tw/files/1/EA184E4A5D153EFDE050007F01006632
it maybe kind of complicated for me.
so i have another board of stm32
nucleo-F410RB
maybe i should start with this as a practice first?
i am not meaning to use the inbuilded edge impulse option of stm32 software
i want to build a library and be used by the corresponding devices
the optimization and speed of mcu may not be enough to run the model , but i want to figure out how to do in the first place
thank you
Hi,
em…
i have no much knowledge in Makefile.
i have tried to add some flags and words but it seems not working
C:\Users\uveuv\Downloads\example-standalone-inferencing-with-library-master\C\static>make -j 4
cc -mcpu=cortex-m4 -mthumb -Wall -g -Wno-strict-aliasing -DEIDSP_SIGNAL_C_FN_POINTER=1 -DEI_C_LINKAGE=1 -I. -Os -DNDEBUG -g -c edge-impulse-sdk/CMSIS/DSP/Source/BasicMathFunctions/arm_xor_u8.c -o edge-impulse-sdk/CMSIS/DSP/Source/BasicMathFunctions/arm_xor_u8.o
process_begin: CreateProcess(NULL, cc -mcpu=cortex-m4 -mthumb -Wall -g -Wno-strict-aliasing -DEIDSP_SIGNAL_C_FN_POINTER=1 -DEI_C_LINKAGE=1 -I. -Os -DNDEBUG -g -c edge-impulse-sdk/CMSIS/DSP/Source/BasicMathFunctions/arm_xor_u8.c -o edge-impulse-sdk/CMSIS/DSP/Source/BasicMathFunctions/arm_xor_u8.o, ...) failed.
make (e=2): 系統找不到指定的檔案。
make: *** [Makefile:91: edge-impulse-sdk/CMSIS/DSP/Source/BasicMathFunctions/arm_xor_u8.o] Error 2
Can you just show an example for building such a library?
my so far added some words Makefile is this
NAME = edge-impulse-standalone
CC ?= gcc
CXX ?= g++
AR ?=ar
CFLAGS += -mcpu=cortex-m4
CFLAGS += -mthumb
CFLAGS += -Wall -g -Wno-strict-aliasing
CFLAGS += -DEIDSP_SIGNAL_C_FN_POINTER=1 -DEI_C_LINKAGE=1
CFLAGS += -I.
CFLAGS += -Os
CFLAGS += -DNDEBUG
CFLAGS += -g
CXXFLAGS += -std=c++11
LDFLAGS += -mcpu=cortex-m4
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -lm -lstdc++
CSOURCES = $(wildcard edge-impulse-sdk/CMSIS/DSP/Source/BasicMathFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/DSP/Source/FastMathFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/DSP/Source/StatisticsFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/DSP/Source/TransformFunctions/*fft*.c) \
$(wildcard edge-impulse-sdk/CMSIS/DSP/Source/CommonTables/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/DSP/Source/TransformFunctions/*bit*.c) \
$(wildcard edge-impulse-sdk/CMSIS/DSP/Source/MatrixFunctions/*.c)
CXXSOURCES = $(wildcard tflite-model/*.cpp) \
$(wildcard edge-impulse-sdk/dsp/kissfft/*.cpp) \
$(wildcard edge-impulse-sdk/dsp/dct/*.cpp) \
$(wildcard ./edge-impulse-sdk/dsp/memory.cpp) \
$(wildcard ./edge-impulse-sdk/classifier/*.cpp)\
$(wildcard edge-impulse-sdk/porting/mbed/*.cpp)
CCSOURCES = $(wildcard edge-impulse-sdk/tensorflow/lite/kernels/*.cc) \
$(wildcard edge-impulse-sdk/tensorflow/lite/kernels/internal/*.cc) \
$(wildcard edge-impulse-sdk/tensorflow/lite/micro/kernels/*.cc) \
$(wildcard edge-impulse-sdk/tensorflow/lite/micro/*.cc) \
$(wildcard edge-impulse-sdk/tensorflow/lite/micro/memory_planner/*.cc) \
$(wildcard edge-impulse-sdk/tensorflow/lite/core/api/*.cc)
APP_CSOURCES = $(wildcard source/*.c)
ifeq (${CMSIS_NN},1)
CFLAGS += -Wno-unknown-attributes
CFLAGS += -DEI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN=1 -D__ARM_FEATURE_DSP=1 -D__GNUC_PYTHON__=1
CFLAGS += -Iedge-impulse-sdk/CMSIS/NN/Include/
CFLAGS += -Iedge-impulse-sdk/CMSIS/DSP/PrivateInclude/
CSOURCES += $(wildcard edge-impulse-sdk/CMSIS/NN/Source/ActivationFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/NN/Source/BasicMathFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/NN/Source/ConcatenationFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/NN/Source/ConvolutionFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/NN/Source/FullyConnectedFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/NN/Source/NNSupportFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/NN/Source/PoolingFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/NN/Source/ReshapeFunctions/*.c) \
$(wildcard edge-impulse-sdk/CMSIS/NN/Source/SoftmaxFunctions/*.c)
endif
# end Target specific
COBJECTS := $(patsubst %.c,%.o,$(CSOURCES))
CXXOBJECTS := $(patsubst %.cpp,%.o,$(CXXSOURCES))
CCOBJECTS := $(patsubst %.cc,%.o,$(CCSOURCES))
APP_COBJECTS = $(patsubst %.c,%.o,$(APP_CSOURCES))
# Host specific
ifeq ($(OS),Windows_NT)
MKDIR_BUILD = if not exist build mkdir build
else
MKDIR_BUILD = mkdir -p build
endif
#end host specific
# Target specific
all: app
.PHONY: app clean
$(COBJECTS) : %.o : %.c
$(CXXOBJECTS) : %.o : %.cpp
$(CCOBJECTS) : %.o : %.cc
$(APP_COBJECTS) : %.o : %.c
%.o: %.c
$(CC) $(CFLAGS) -c $^ -o $@
%.o: %.cc
$(CXX) $(CFLAGS) $(CXXFLAGS) -c $^ -o $@
%.o: %.cpp
$(CXX) $(CFLAGS) $(CXXFLAGS) -c $^ -o $@
build/libedgeimpulse.a: $(COBJECTS) $(CXXOBJECTS) $(CCOBJECTS)
$(MKDIR_BUILD)
$(AR) rcs build/libedgeimpulse.a $(COBJECTS) $(CXXOBJECTS) $(CCOBJECTS)
app: $(APP_COBJECTS) build/libedgeimpulse.a
$(MKDIR_BUILD)
$(CXX) $(APP_COBJECTS) build/libedgeimpulse.a -o build/$(NAME) $(LDFLAGS)
clean:
ifeq ($(OS),Windows_NT)
del /Q $(subst /,\,$(patsubst %.c,%.o,$(CSOURCES))) >nul 2>&1 || exit 0
del /Q $(subst /,\,$(patsubst %.cpp,%.o,$(CXXSOURCES))) >nul 2>&1 || exit 0
del /Q $(subst /,\,$(patsubst %.cc,%.o,$(CCSOURCES))) >nul 2>&1 || exit 0
del /Q $(subst /,\,$(patsubst %.c,%.o,$(APP_COBJECTS))) >nul 2>&1 || exit 0
del /Q build\libedgeimpulse.a >nul 2>&1 || exit 0
else
rm -f $(COBJECTS)
rm -f $(CCOBJECTS)
rm -f $(CXXOBJECTS)
rm -f $(APP_COBJECTS)
rm -f build/libedgeimpulse.a
endif
Hi @uveuvenouve
Which terminal are you using on Windows?
Your error seems to suggest a issue with PATH
. Take a look at answer from Ricardo Alejos at windows - Makefile error make (e=2): The system cannot find the file specified - Stack Overflow.
Can you try adding <git-installation-directory>/usr/bin
to you’re PATH
environmental variable.
Hi @rjames
i think it just can’t find arm_xor_u8.o
but i don’t know why
maybe it didn’t compile out the arm_xor_u8.o
i expect it should compile like standalone example cause the makefile seems the same besides of some other flag added
Which terminal are you using? What’s the value of PATH
?
Can you add @echo %PATH%
in the makefile and return the value of PATH
.
Otherwise can you try using git bash
instead?
See also tkennon
response in the same stack overflow link i previously shared, regarding make. Check with Make you are using, GNU Make vs mingw32-make.
sorry for long time not replying
too frustrated for no being able to compile the “.so” out
i have tested only adding those c++ folder in stm32 board and succeed to run my inference example
but i need to select compile with c++ at the beginning of starting a stm32 project
but for the sonix project, that is base on C
and seems impossible to change the whole project to C++ based
and i think i need to figure out how to compile a “.so” out to make this work
So continue on the make problem
i downloaded mingw64 and MinGW
only the mingw64 can use mingw32-make command
but both of them have errors on compiling
C:\Users\Wing\Desktop\example-standalone-inferencing-with-library-master\C\static>mingw32-make
cc -Wall -g -Wno-strict-aliasing -DEIDSP_SIGNAL_C_FN_POINTER=1 -DEI_C_LINKAGE=1 -I. -Os -DNDEBUG -g -c edge-impulse-sdk/tensorflow/lite/c/common.c -o edge-impulse-sdk/tensorflow/lite/c/common.o
process_begin: CreateProcess(NULL, cc -Wall -g -Wno-strict-aliasing -DEIDSP_SIGNAL_C_FN_POINTER=1 -DEI_C_LINKAGE=1 -I. -Os -DNDEBUG -g -c edge-impulse-sdk/tensorflow/lite/c/common.c -o edge-impulse-sdk/tensorflow/lite/c/common.o, …) failed.
make (e=2): The system cannot find the file specified.
mingw32-make: *** [Makefile:57: edge-impulse-sdk/tensorflow/lite/c/common.o] Error 2
btw i still can’t figure out what cflag do i need to add
i just added LDFLAGS += -mcpu=cortex-m4
and changed the porting as the following
CXXSOURCES += $(wildcard edge-impulse-sdk/porting/mingw32/.c) $(wildcard edge-impulse-sdk/porting/mbed/.c)
is that correct?
I can build a .a file with the origin code in make file now
but when i add these line
CC=armclang
CXX=armclang
AR=armar
it shows error
rary/C/static$ ./build.sh
Building standalone classifier
Running MAKE in single-threaded mode
armclang -m32 -Wall -g -Wno-strict-aliasing -DEIDSP_SIGNAL_C_FN_POINTER=1 -DEI_C_LINKAGE=1 -I. -Os -DNDEBUG -g -march=armv7-m -mtune=cortex-m3 -c edge-impulse-sdk/tensorflow/lite/c/common.c -o edge-impulse-sdk/tensorflow/lite/c/common.o
make: armclang: Command not found
Makefile:64: recipe for target ‘edge-impulse-sdk/tensorflow/lite/c/common.o’ failed
make: *** [edge-impulse-sdk/tensorflow/lite/c/common.o] Error 127
search for solution on web
seems is missing compiler problem
trying to fix
i missed the very early reply issue
i need to compile with the same compiler as the project…
and now i got a bat file from the project
it is way different than makefile
do you have any suggestion?
chatgpt seems making it with different compiler other than armcc