I have a Makefile which contains a target by name abc-def-ghi. When I compile this particular target in my Linux machine with the command make abc-def-ghi, it builds successfully, but when the same target is tried to built in Yocto using oe_runmake abc-def-ghi command, I get an error which I am not able to find the root cause of it.
Error:
2025年12月20日T09:12:31 | make: *** No rule to make target 'abc-def-ghi'. Stop.
2025年12月20日T09:12:31 | ERROR: oe_runmake failed
Makefile:
LIBNAME = libda
SOLIBNAME = $(LIBNAME).so
BINNAME = abc-def-ghi
SRC_DIR := src
SRCS := $(shell find $(SRC_DIR) -name '*.cpp')
OBJS := $(SRCS:.cpp=.o)
INCLUDES := -I.
CXXFLAGS += $(INCLUDES) -std=c++17 -Wall -Wextra -fPIC
LDFLAGS += \
-L../libs \
-lda
all: $(BINNAME)
$(SOLIBNAME): lib.o
g++ -shared -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
LDFLAGS += \
-L. \
-lda
$(BINNAME): $(SOLIBNAME) $(OBJS)
g++ -o $@ $(OBJS) $(CXXFLAGS) $(LDFLAGS)
install:
install -Dm 0755 $(SOLIBNAME) /usr/local/lib/
install -Dm 0755 $(BINNAME) /usr/local/bin/
clean:
rm -f $(LIBNAME) $(BINNAME) src/*.o
abc.bb:
SUMMARY = "ABC"
DESCRIPTION = "This package contains ABC"
inherit git-utils
inherit tools
inherit ${@'make-qnx' if d.getVar('BUILD_PLATFORM') == 'QNX' else ''}
SRC_URI = "gitsm://gitlab.a.b.com/c/proj;branch=main;protocol=https"
SRCREV_FORMAT = "proj"
SRCREV = "${AUTOREV}"
S = "${WORKDIR}/git/proj/abc"
do_compile() {
oe_runmake "abc-def-ghi"
}
FILES:${PN} += " \
${sysconfdir}/${BPN}/abc-def-ghi \
"
do_compile:prepend:qnx() {
PATH=$PATH:${QNX_HOST}/usr/bin
install -d ${RECIPE_SYSROOT}/usr/lib/proj/
}
The Makefile resides inside proj/abc.
1 Answer 1
Your makefile cannot be used for cross-compilation, because it contains hard coded values. Replace all the hard coded tools like g++ with the variables provided by the Yocto environment.
Also, you may need to inherit some classes in the recipe it you use something like autotools (then it would be inherit autotools). If you use plain makefiles, no explicit inherit is needed, as base class is inhertied automatically.
Side note: that same base.bbclass should also take care of running oe_runmake and adding the binary to FILES, if your makefile contains the needed information.
For example replace this line:
g++ -o $@ $(OBJS) $(CXXFLAGS) $(LDFLAGS)
with
$(CXX) -o $@ $(OBJS) $(CXXFLAGS) $(LDFLAGS)
makeis executed in a different working directory relative to the source than when you test runningmakedirectly.Sexplicilty).