英文:
Link correct version of shared library from Yocto recipe
问题
I have a versioned library, mylib
installed by, mylib.bb
:
...
TARGET_CC_ARCH += "${LDFLAGS}"
do_compile() {
${CC} -c -o mylib.o ${S}/mylib.c
${CC} -shared -o libmylib.so mylib.o
${AR} rcs libmylib.a mylib.o
}
do_install() {
install -Dm0644 libmylib.so ${D}${libdir}/libmylib.so.0.1
ln -srf ${D}${libdir}/libmylib.so.0.1 ${D}${libdir}/libmylib.so.0
ln -srf ${D}${libdir}/libmylib.so.0 ${D}${libdir}/libmylib.so
install -Dm0644 libmylib.a ${D}${libdir}/libmylib.a
install -Dm0644 ${S}/mylib.h ${D}${includedir}/mylib.h
}
FILES_${PN} = "\
${libdir}/libmylib.a \
${libdir}/libmylib.so.0 \
${libdir}/libmylib.so.0.1 \
"
This seems to install files in the correct packages:
├── packages-split
│   ├── mylib
│   │   └── usr
│   │   └── lib
│   │   ├── libmylib.so.0 -> libmylib.so.0.1
│   │   └── libmylib.so.0.1
│   ├── mylib-dbg
│   │   └── usr
│   │   └── lib
│   ├── mylib-dev
│   │   └── usr
│   │   ├── include
│   │   │   └── mylib.h
│   │   └── lib
│   │   └── libmylib.so -> libmylib.so.0.1
│   ├── mylib-doc
│   ├── mylib-locale
│   ├── mylib-src
│   └── mylib-staticdev
│   └── usr
│   └── lib
│   └── libmylib.a
I now have another application build by another recipe, myapp.bb
:
...
DEPENDS = " \
qtbase \
mylib \
"
RDEPENDS_${PN} = " \
qtbase \
mylib \
"
...
inherit cmake_qt5
There exists a target with the following:
...
find_library(MYLIB_LIB mylib)
...
target_link_libraries(
myapp
PRIVATE
Qt5::Core
${MYLIB_LIBS}
)
When I run bitbake myapp
, I get the following QA error:
ERROR: myapp-1.0+gitAUTOINC+11b975a273-r0 do_package_qa: QA Issue: /usr/bin/myapp contained in package myapp requires libmylib.so()(64bit), but no providers found in RDEPENDS_myapp? [file-rdeps]
ERROR: myapp-1.0+gitAUTOINC+11b975a273-r0 do_package_qa: QA run found fatal errors. Please consider fixing them.
ERROR: Logfile of failure stored in: /project/build/tmp/work/aarch64-poky-linux/myapp/1.0+gitAUTOINC+11b975a273-r0/temp/log.do_package_qa.630508
ERROR: Task (/project/sources/meta-b9/meta-b9/recipes-b9/myapp/myapp_0.bb:do_package_qa) failed with exit code '1'
When I look at the compile step I see the flag -lmylib
where I would expect the path to mylib.so.1
. Why is this and what can I do to fix it so I can build myapp
with my recipe?
英文:
I have a versioned library, mylib
installed by, mylib.bb
:
...
TARGET_CC_ARCH += "${LDFLAGS}"
do_compile() {
${CC} -c -o mylib.o ${S}/mylib.c
${CC} -shared -o libmylib.so mylib.o
${AR} rcs libmylib.a mylib.o
}
do_install() {
install -Dm0644 libmylib.so ${D}${libdir}/libmylib.so.0.1
ln -srf ${D}${libdir}/libmylib.so.0.1 ${D}${libdir}/libmylib.so.0
ln -srf ${D}${libdir}/libmylib.so.0 ${D}${libdir}/libmylib.so
install -Dm0644 libmylib.a ${D}${libdir}/libmylib.a
install -Dm0644 ${S}/mylib.h ${D}${includedir}/mylib.h
}
FILES_${PN} = "\
${libdir}/libmylib.a \
${libdir}/libmylib.so.0 \
${libdir}/libmylib.so.0.1 \
"
This seems to install files in the correct packages:
├── packages-split
│   ├── mylib
│   │   └── usr
│   │   └── lib
│   │   ├── libmylib.so.0 -> libmylib.so.0.1
│   │   └── libmylib.so.0.1
│   ├── mylib-dbg
│   │   └── usr
│   │   └── lib
│   ├── mylib-dev
│   │   └── usr
│   │   ├── include
│   │   │   └── mylib.h
│   │   └── lib
│   │   └── libmylib.so -> libmylib.so.0.1
│   ├── mylib-doc
│   ├── mylib-locale
│   ├── mylib-src
│   └── mylib-staticdev
│   └── usr
│   └── lib
│   └── libmylib.a
I now have another application build by another recipe, myapp.bb
:
...
DEPENDS = " \
qtbase \
mylib \
"
RDEPENDS_${PN} = " \
qtbase \
mylib \
"
...
inherit cmake_qt5
There exists a target with the following:
...
find_library(MYLIB_LIB mylib)
...
target_link_libraries(
myapp
PRIVATE
Qt5::Core
${MYLIB_LIBS}
)
When I run bitbake myapp
, I get the following QA error:
ERROR: myapp-1.0+gitAUTOINC+11b975a273-r0 do_package_qa: QA Issue: /usr/bin/myapp contained in package myapp requires libmylib.so()(64bit), but no providers found in RDEPENDS_myapp? [file-rdeps]
ERROR: myapp-1.0+gitAUTOINC+11b975a273-r0 do_package_qa: QA run found fatal errors. Please consider fixing them.
ERROR: Logfile of failure stored in: /project/build/tmp/work/aarch64-poky-linux/myapp/1.0+gitAUTOINC+11b975a273-r0/temp/log.do_package_qa.630508
ERROR: Task (/project/sources/meta-b9/meta-b9/recipes-b9/myapp/myapp_0.bb:do_package_qa) failed with exit code '1'
When I look at the compile step I see the flag -lmylib
where I would expect the path to mylib.so.1
. Why is this and what can I do to fix it so I can build myapp
with my recipe?
答案1
得分: 0
The linker flag -soname
must be specified. When building the library. This can be done indirectly through the compiler by adding the option -Wl,-soname,...
所以 do_compile
步骤看起来会是这样的:
do_compile() {
${CC} -c -o mylib.o ${S}/mylib.c
${CC} -shared -Wl,-soname,libmylib.so.0.1 -o libmylib.so mylib.o
${AR} rcs libmylib.a mylib.o
}
英文:
The linker flag -soname
must be specified. When building the library. This can be done indirectly through the compiler by adding the option -Wl,-soname,...
So the do_compile
step would look something like:
do_compile() {
${CC} -c -o mylib.o ${S}/mylib.c
${CC} -shared -Wl,-soname,libmylib.so.0.1 -o libmylib.so mylib.o
${AR} rcs libmylib.a mylib.o
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论