Skip to contentSkip to conversation

Makefile library and debian naming

DISCUSSION Guy Morand 2 participants 5 messages Nov 21, 2017

lore
Share & tools
lore

Guy Morand

author
#0 lore raw

Hallo Yocto developpers!

I'm trying to build a Makefile based library. The recipe looks like this:
---[recipe mesages.bb]---
# SNIP recipe header

do_compile() {
oe_runmake LDFLAGS="${LDFLAGS}" shared-lib
oe_runmake LDFLAGS="${LDFLAGS}" static-lib
}

do_install() {
oe_runmake install DESTDIR=${D}${prefix}

  # Fix pkg-config
  sed -i 's,${D},,g' ${D}/usr/lib/pkgconfig/messages.pc

# FIXME: Try to make a debian package libmessages instead # This avoids errors when installing an app linking with this library! rm ${D}/${libdir}/lib${PN}.so
}
---[/recipe mesages.bb]---

The resulted image in WORKDIR looks like this:
---[WORKDIR/image]---
image/usr/lib/libmessages.so.0.3.0
image/usr/lib/libmessages.so.0
image/usr/lib/libmessages.a
image/usr/lib/pkgconfig/messages.pc
image/usr/include/messages/<all my headers>
---[/WORKDIR/image]---

The generated ipk packages are:
---[ipks]---
messages-dev_git.ipk
messages_git.ipk
messages-staticdev_git.ipk
messages-dbg_git.ipk
---[/ipks]---

The problem is that an application compiled with this library links against the static library. If I don't remove the .so file from the recipe, my application fails installing:
---[bitbake error]---
ERROR: myApp do_package_qa: QA Issue: /usr/bin/myApp contained in package myApp requires libmessages.so, but no providers found in RDEPENDS_myApp? [file-rdeps] ---[/bitbake error]---

Probably because the .so gets packed in the messages-dev.ipk ...

The strange thing is that I would expect a generated ipk with debian naming such as:
libmessages_git.ipk
libmessages-dbg_git.ipk
libmessages-dev_git.ipk
libmessages-staticdev_git.ipk

I have other libraries based on cmake and everything works as expected!

Despite the recipe already inherits "debian", explicitly inheriting this class doesn't help.

What am I doing wrong?

Guy Morand

#1 lore raw

You don't need to inherit debian in a recipe, that is meant to be a distro-level inherit (and is inherited out of the box).

Deleting the .so breaks non-static linking as that is the file which is used to link against, so don't delete it. It should be in the -dev package.

The QA error is probably because your library is built wrong in the makefile. Another indication of this is the lack of renaming. Look at the makefile, specifically the specified soname.

Ross

Quoted 73 lines · Guy Morand

Hallo Yocto developpers!

I'm trying to build a Makefile based library. The recipe looks like this:
---[recipe mesages.bb]---
# SNIP recipe header

do_compile() {
oe_runmake LDFLAGS="${LDFLAGS}" shared-lib
oe_runmake LDFLAGS="${LDFLAGS}" static-lib
}

do_install() {
oe_runmake install DESTDIR=${D}${prefix}

  # Fix pkg-config
  sed -i 's,${D},,g' ${D}/usr/lib/pkgconfig/messages.pc

# FIXME: Try to make a debian package libmessages instead # This avoids errors when installing an app linking with this library! rm ${D}/${libdir}/lib${PN}.so
}
---[/recipe mesages.bb]---

The resulted image in WORKDIR looks like this:
---[WORKDIR/image]---
image/usr/lib/libmessages.so.0.3.0
image/usr/lib/libmessages.so.0
image/usr/lib/libmessages.a
image/usr/lib/pkgconfig/messages.pc
image/usr/include/messages/<all my headers>
---[/WORKDIR/image]---

The generated ipk packages are:
---[ipks]---
messages-dev_git.ipk
messages_git.ipk
messages-staticdev_git.ipk
messages-dbg_git.ipk
---[/ipks]---

The problem is that an application compiled with this library links against the static library. If I don't remove the .so file from the recipe, my application fails installing:
---[bitbake error]---
ERROR: myApp do_package_qa: QA Issue: /usr/bin/myApp contained in package myApp requires libmessages.so, but no providers found in RDEPENDS_myApp? [file-rdeps]
---[/bitbake error]---

Probably because the .so gets packed in the messages-dev.ipk ...

The strange thing is that I would expect a generated ipk with debian naming such as:
libmessages_git.ipk
libmessages-dbg_git.ipk
libmessages-dev_git.ipk
libmessages-staticdev_git.ipk

I have other libraries based on cmake and everything works as expected!

Despite the recipe already inherits "debian", explicitly inheriting this class doesn't help.

What am I doing wrong?

Guy Morand
--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

author
#2 lore raw

Ross,

Thanks for your quick reply!

No, I don't inherit debian and wish I could leave the so file as is, it was just a quick and dirty hack to compile my image.

Quoted 2 lines

Another indication of this is the lack of renaming. Look at the makefile, specifically the specified soname.

The Makefile is written by myself. The library is built as follow:
$(SHARED_OUT_DIR)/%.o: %.c

	$(CC) $(CFLAGS) -fPIC -c -o $@ $<

$(SHARED_OUT_DIR)/$(SHARED_LIB_NAME): $(SHARED_OBJS)

	$(CC) -shared $(LDFLAGS) $(SHARED_OBJS) -o $@

What do you mean with "lack of renaming", do you have some pointers? Something with LDFLAGS? What is the specified "soname"?

Guy

Quoted 87 lines · Ross

You don't need to inherit debian in a recipe, that is meant to be a distro-level inherit (and is inherited out of the box).

Deleting the .so breaks non-static linking as that is the file which is used to link against, so don't delete it.  It should be in the -dev package.

The QA error is probably because your library is built wrong in the makefile.  Another indication of this is the lack of renaming.  Look at the makefile, specifically the specified soname.

Ross

On 21 November 2017 at 13:00, Guy Morand <[email protected] <mailto:[email protected]>> wrote:

Hallo Yocto developpers!

I'm trying to build a Makefile based library. The recipe looks like this:
---[recipe mesages.bb <http://mesages.bb>]---
# SNIP recipe header

do_compile() {
  oe_runmake LDFLAGS="${LDFLAGS}" shared-lib
  oe_runmake LDFLAGS="${LDFLAGS}" static-lib
}

do_install() {
  oe_runmake install DESTDIR=${D}${prefix}

  # Fix pkg-config
  sed -i 's,${D},,g' ${D}/usr/lib/pkgconfig/messages.pc

  # FIXME: Try to make a debian package libmessages instead # This avoids errors when installing an app linking with this
library!
  rm ${D}/${libdir}/lib${PN}.so
}
---[/recipe mesages.bb <http://mesages.bb>]---

The resulted image in WORKDIR looks like this:
---[WORKDIR/image]--- image/usr/lib/libmessages.so.0.3.0 image/usr/lib/libmessages.so.0 image/usr/lib/libmessages.a image/usr/lib/pkgconfig/messages.pc image/usr/include/messages/<all my headers> ---[/WORKDIR/image]---

The generated ipk packages are:
---[ipks]---
messages-dev_git.ipk
messages_git.ipk
messages-staticdev_git.ipk
messages-dbg_git.ipk
---[/ipks]---

The problem is that an application compiled with this library links against the static library. If I don't remove the .so file from the recipe, my application fails installing:
---[bitbake error]---
ERROR: myApp do_package_qa: QA Issue: /usr/bin/myApp contained in package myApp requires libmessages.so, but no providers found in RDEPENDS_myApp? [file-rdeps]
---[/bitbake error]---

Probably because the .so gets packed in the messages-dev.ipk ...

The strange thing is that I would expect a generated ipk with debian naming such as:
libmessages_git.ipk
libmessages-dbg_git.ipk
libmessages-dev_git.ipk
libmessages-staticdev_git.ipk

I  have other libraries based on cmake and everything works as expected!

Despite the recipe already inherits "debian", explicitly inheriting this class doesn't help.

What am I doing wrong?

Guy Morand
--
_______________________________________________
yocto mailing list
[email protected] <mailto:[email protected]>
https://lists.yoctoproject.org/listinfo/yocto
<https://lists.yoctoproject.org/listinfo/yocto>

author
#3 lore raw

Ok a quick search on the Internet and I've found out that I probably miss some linker parameters such as:
-Wl,-soname,libmessages.so.0

Great, I have the feeling I learned something important today!

Thanks for the pointers!

Guy

Quoted 107 lines · Guy Morand

Ross,

Thanks for your quick reply!

No, I don't inherit debian and wish I could leave the so file as is, it was just a quick and dirty hack to compile my image.

Quoted 2 lines

Another indication of this is the lack of renaming.  Look at the makefile, specifically the specified soname.

The Makefile is written by myself. The library is built as follow:
$(SHARED_OUT_DIR)/%.o: %.c
    $(CC) $(CFLAGS) -fPIC -c -o $@ $<

$(SHARED_OUT_DIR)/$(SHARED_LIB_NAME): $(SHARED_OBJS)
    $(CC) -shared $(LDFLAGS) $(SHARED_OBJS) -o $@

What do you mean with "lack of renaming", do you have some pointers? Something with LDFLAGS? What is the specified "soname"?

Guy

Quoted 86 lines · Ross

You don't need to inherit debian in a recipe, that is meant to be a distro-level inherit (and is inherited out of the box).

Deleting the .so breaks non-static linking as that is the file which is used to link against, so don't delete it.  It should be in the -dev package.

The QA error is probably because your library is built wrong in the makefile.  Another indication of this is the lack of renaming.  Look at the makefile, specifically the specified soname.

Ross

On 21 November 2017 at 13:00, Guy Morand <[email protected] <mailto:[email protected]>> wrote:

    Hallo Yocto developpers!

    I'm trying to build a Makefile based library. The recipe looks like this:
    ---[recipe mesages.bb <http://mesages.bb>]---
    # SNIP recipe header

    do_compile() {
       oe_runmake LDFLAGS="${LDFLAGS}" shared-lib
       oe_runmake LDFLAGS="${LDFLAGS}" static-lib
    }

    do_install() {
       oe_runmake install DESTDIR=${D}${prefix}

       # Fix pkg-config
       sed -i 's,${D},,g' ${D}/usr/lib/pkgconfig/messages.pc

       # FIXME: Try to make a debian package libmessages instead # This avoids errors when installing an app linking with this library!
       rm ${D}/${libdir}/lib${PN}.so
    }
    ---[/recipe mesages.bb <http://mesages.bb>]---

    The resulted image in WORKDIR looks like this:
    ---[WORKDIR/image]--- image/usr/lib/libmessages.so.0.3.0 image/usr/lib/libmessages.so.0 image/usr/lib/libmessages.a image/usr/lib/pkgconfig/messages.pc image/usr/include/messages/<all my headers> ---[/WORKDIR/image]---

    The generated ipk packages are:
    ---[ipks]---
    messages-dev_git.ipk
    messages_git.ipk
    messages-staticdev_git.ipk
    messages-dbg_git.ipk
    ---[/ipks]---

    The problem is that an application compiled with this library links against the static library. If I don't remove the .so file from the recipe, my application fails installing:
    ---[bitbake error]---
    ERROR: myApp do_package_qa: QA Issue: /usr/bin/myApp contained in package myApp requires libmessages.so, but no providers found in RDEPENDS_myApp? [file-rdeps]
    ---[/bitbake error]---

    Probably because the .so gets packed in the messages-dev.ipk ...

    The strange thing is that I would expect a generated ipk with debian naming such as:
    libmessages_git.ipk
    libmessages-dbg_git.ipk
    libmessages-dev_git.ipk
    libmessages-staticdev_git.ipk

    I  have other libraries based on cmake and everything works as expected!

    Despite the recipe already inherits "debian", explicitly inheriting this class doesn't help.

    What am I doing wrong?

    Guy Morand
    --     _______________________________________________ yocto mailing list
    [email protected] <mailto:[email protected]>
    https://lists.yoctoproject.org/listinfo/yocto
    <https://lists.yoctoproject.org/listinfo/yocto>

#4 lore raw

Yes, that :)

http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

Ross

Quoted 135 lines · Guy Morand

Ok a quick search on the Internet and I've found out that I probably miss some linker parameters such as:
-Wl,-soname,libmessages.so.0

Great, I have the feeling I learned something important today!

Thanks for the pointers!

Guy

Quoted 15 lines · Guy Morand

Ross,

Thanks for your quick reply!

No, I don't inherit debian and wish I could leave the so file as is, it was just a quick and dirty hack to compile my image.

Quoted 2 lines

Another indication of this is the lack of renaming. Look at the makefile, specifically the specified soname.

The Makefile is written by myself. The library is built as follow:
$(SHARED_OUT_DIR)/%.o: %.c

     $(CC) $(CFLAGS) -fPIC -c -o $@ $<

$(SHARED_OUT_DIR)/$(SHARED_LIB_NAME): $(SHARED_OBJS)

Quoted 102 lines
     $(CC) -shared $(LDFLAGS) $(SHARED_OBJS) -o $@

What do you mean with "lack of renaming", do you have some pointers? Something with LDFLAGS? What is the specified "soname"?

Guy

Quoted 93 lines · Ross

You don't need to inherit debian in a recipe, that is meant to be a distro-level inherit (and is inherited out of the box).

Deleting the .so breaks non-static linking as that is the file which is used to link against, so don't delete it. It should be in the -dev package.

The QA error is probably because your library is built wrong in the makefile. Another indication of this is the lack of renaming. Look at the makefile, specifically the specified soname.

Ross

On 21 November 2017 at 13:00, Guy Morand <[email protected] <mailto:
[email protected]>> wrote:

Hallo Yocto developpers!

I'm trying to build a Makefile based library. The recipe looks like this:
---[recipe mesages.bb <http://mesages.bb>]---
# SNIP recipe header

do_compile() {
oe_runmake LDFLAGS="${LDFLAGS}" shared-lib
oe_runmake LDFLAGS="${LDFLAGS}" static-lib
}

do_install() {
oe_runmake install DESTDIR=${D}${prefix}

# Fix pkg-config
sed -i 's,${D},,g' ${D}/usr/lib/pkgconfig/messages.pc

# FIXME: Try to make a debian package libmessages instead # This avoids errors when installing an app linking with this
library!
rm ${D}/${libdir}/lib${PN}.so
}
---[/recipe mesages.bb <http://mesages.bb>]---

The resulted image in WORKDIR looks like this:
---[WORKDIR/image]--- image/usr/lib/libmessages.so.0.3.0 image/usr/lib/libmessages.so.0 image/usr/lib/libmessages.a image/usr/lib/pkgconfig/messages.pc image/usr/include/messages/<all my headers> ---[/WORKDIR/image]---

The generated ipk packages are:
---[ipks]---
messages-dev_git.ipk
messages_git.ipk
messages-staticdev_git.ipk
messages-dbg_git.ipk
---[/ipks]---

The problem is that an application compiled with this library links against the static library. If I don't remove the .so file from the recipe, my application fails installing:
---[bitbake error]---
ERROR: myApp do_package_qa: QA Issue: /usr/bin/myApp contained in package myApp requires libmessages.so, but no providers found in RDEPENDS_myApp? [file-rdeps]
---[/bitbake error]---

Probably because the .so gets packed in the messages-dev.ipk ...

The strange thing is that I would expect a generated ipk with debian naming such as:
libmessages_git.ipk
libmessages-dbg_git.ipk
libmessages-dev_git.ipk
libmessages-staticdev_git.ipk

I have other libraries based on cmake and everything works as
expected!

Despite the recipe already inherits "debian", explicitly inheriting this class doesn't help.

What am I doing wrong?

Guy Morand
-- _______________________________________________
yocto mailing list
[email protected] <mailto:[email protected]>
https://lists.yoctoproject.org/listinfo/yocto
<https://lists.yoctoproject.org/listinfo/yocto>

--

_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto