Cross-compiling opkg?

1,862 views
Skip to first unread message

Fred

unread,
Apr 8, 2011, 10:43:41 AM4/8/11
to opkg-devel
Hello,

I'd like to cross-compile opkg for use on an uClinux-based appliance.

After successfully (?) cross-compiling libcurl, I downloaded
opkg-576.tar.gz from
http://downloads.openwrt.org/sources/, ran ./autogen.sh, and then ran
the following command:

============
#PATH has been edited to include path to cross-compiler

./configure --host=i686-pc-linux-gnu --target=bfin-linux-uclibc
CC=bfin-linux-uclibc-gcc CFLAGS="-O2 -Wall -ansi -pedantic
-I/usr/src/switchfin/build_ip01/uClinux-dist/linux-2.6.x/include
-I/usr/src/switchfin/build_ip01/uClinux-dist/staging/usr/include"
AR="bfin-linux-uclibc-ar" RANLIB="bfin-linux-uclibc-ranlib"
CURL_LIBS="-L/usr/src/switchfin/build_ip01/uClinux-dist/lib/libcurl/
build-curl-7.19.2/lib/.libs"
============

But configure complains with "No package 'libcurl' found".

I'm no Autotools expert, and have no clue why configure can't find
Libcurl although I used the recommended CURL_LIBS parameter.

Does someone know the solution to this?

Thank you.

Fred

unread,
Apr 9, 2011, 4:07:02 AM4/9/11
to opkg-devel
On 8 avr, 16:43, Fred <frdthe...@gmail.com> wrote:
> ./configure --host=i686-pc-linux-gnu --target=bfin-linux-uclibc
> CC=bfin-linux-uclibc-gcc CFLAGS="-O2 -Wall -ansi -pedantic
> -I/usr/src/switchfin/build_ip01/uClinux-dist/linux-2.6.x/include
> -I/usr/src/switchfin/build_ip01/uClinux-dist/staging/usr/include"
> AR="bfin-linux-uclibc-ar" RANLIB="bfin-linux-uclibc-ranlib"
> CURL_LIBS="-L/usr/src/switchfin/build_ip01/uClinux-dist/lib/libcurl/
> build-curl-7.19.2/lib/.libs"
> ============
>
> But configure complains with "No package 'libcurl' found".

The solution, provided you do not want to use curl, is to disable it
with the following switch: "--disable-cur"

Likewise, if you don't want to use GPGME, use the following switch: "--
disable-gpg"

HTH,

Fred

unread,
Apr 10, 2011, 12:41:43 PM4/10/11
to opkg-devel
On 8 avr, 16:43, Fred <frdthe...@gmail.com> wrote:
> But configure complains with "No package 'libcurl' found".

I could proceed by telling "configure" to ignore Curl entirely with
""--disable-curl".

However, linking doesn't succeed:
==============
...
LINK opkg-cl

../libopkg/.libs/libopkg.so: warning: fork: this function is not
implemented on no-mmu systems

Making all in tests

CC libopkg_test.o

LINK libopkg_test


../libopkg/.libs/libopkg.a(libbb_la-gz_open.o): In function `gz_open':

/tmp/opkg-576/libbb/gz_open.c:47: warning: fork: this function is not
implemented on no-mmu systems
==============

Does someone know whether this warning is important and the source
code should be modified so that it uses vfork() instead, or can I just
ignore it?

Thank you.

Graham Gower

unread,
Apr 10, 2011, 7:53:35 PM4/10/11
to opkg-...@googlegroups.com
> --
> You received this message because you are subscribed to the Google Groups "opkg-devel" group.
> To post to this group, send email to opkg-...@googlegroups.com.
> To unsubscribe from this group, send email to opkg-devel+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/opkg-devel?hl=en.
>
>

Sounds like you need to make changes to gz_open.c for it to build. See
r604 for some inspiration.
http://code.google.com/p/opkg/source/detail?r=604

What libc are you liking with?

-Graham

Graham Gower

unread,
Apr 10, 2011, 7:53:57 PM4/10/11
to opkg-...@googlegroups.com
> What libc are you liking with?

Of course, I meant "linking".

Fred

unread,
Apr 11, 2011, 7:25:14 AM4/11/11
to opkg-devel
On 11 avr, 01:53, Graham Gower <graham.go...@gmail.com> wrote:
> Sounds like you need to make changes to gz_open.c for it to build. See
> r604 for some inspiration.http://code.google.com/p/opkg/source/detail?r=604
>
> What libc are you liking with?

Thanks for the tip. Unfortunately, I don't have the skills to dig
deeper and modify source code myself. I was just hoping that I could
go ahead and ignore the warning :-/

Incidently, running "./opkg-cl" works fine when compiled for Ubuntu,
but says "file not found" when ran on the Blackfin. Hard to tell the
cause for the run-time error.

I'm linking with uClibc, using the following configure:

./configure --disable-curl --disable-gpg
ac_cv_func_malloc_0_nonnull=yes --build=i686-pc-linux --host=bfin-
linux-uclibc CC=bfin-linux-uclibc-gcc CFLAGS="-O2 -Wall -I/usr/src/
switchfin/build_ip01/uClinux-dist/linux-2.6.x/include -I/usr/src/
switchfin/build_ip01/uClinux-dist/staging/usr/include" AR="bfin-linux-
uclibc-ar" RANLIB="bfin-linux-uclibc-ranlib"

Fred

unread,
Apr 11, 2011, 7:46:13 AM4/11/11
to opkg-devel
> Incidently, running "./opkg-cl" works fine when compiled for Ubuntu,
> but says "file not found" when ran on the Blackfin. Hard to tell the
> cause for the run-time error.

I see that src/opkg-cl is not a binary, but rather a Bash script, with
the following information:
========
# opkg-cl - temporary wrapper script for .libs/opkg-cl
# Generated by ltmain.sh (GNU libtool) 2.2.6b Debian-2.2.6b-2ubuntu1
#
# The opkg-cl program cannot be directly executed until all the
libtool
# libraries that it depends on are installed.
#
# This wrapper script should never be moved out of the build
directory.
# If it is, it will not operate correctly.
========

I didn't find documentation in the wiki or the tarball about how to
install/use opkg, and whether it'll work on a non-Bash shell (busybox
supports asn and hush).

On the uClinux appliance, what files do I need to install where so I
can test if it works OK?

Thank you.
Message has been deleted

Fred

unread,
Apr 11, 2011, 8:27:48 AM4/11/11
to opkg-devel
Through trial/error, I made some progress:

1. Ignored src/opkg-cl Bash script, and simply copied ./src/.libs/
opkg-
cl and ./libopkg/.libs/libopkg.so.0.0.0 to the appliance in /var/tmp/
opkg directory

2. Created a symlink from libopkg.so.0.0.0 to libopkg.so.0

3. Exported LD_LIBRARY_PATH=/var/tmp/opkg

4. Export OPKG_USE_VFORK=1 (required by gz_open.c to use vfork()
instead of fork())

5. Created /usr/lib/opkg so it can create its "lock" file

6. Created /etc/opkg.conf to include a reference to the old ipkg
repository I'd like to use
src snapshots http://www.acme.com/ipkg
dest root /

7. But when I ran "/var/tmp/opkg/opkg-cl update", it says/does
nothing. Am I
missing something?

Thank you.

Graham Gower

unread,
Apr 11, 2011, 7:25:26 PM4/11/11
to opkg-...@googlegroups.com
On 11 April 2011 21:57, Fred <frdt...@gmail.com> wrote:
> Through trial/error, I made some progress:
>
> 1. Ignored src/opkg-cl Bash script, and simply copied ./src/.libs/
> opkg-
> cl and ./libopkg/.libs/libopkg.so.0.0.0 to the appliance in /var/tmp/
> opkg directory
>
> 2. Created a symlink from libopkg.so.0.0.0 to libopkg.so.0

The src/opkg-cl script is a libtool thing. Libtool creates this so
that one can invoke the binary in place (e.g. without doing a make
install) for testing purposes during development. make install will
basically do what you have done in regards to copying the binary and
library from the .libs directory.

>
> 3. Exported LD_LIBRARY_PATH=/var/tmp/opkg
>
> 4. Export OPKG_USE_VFORK=1 (required by gz_open.c to use vfork()
> instead of fork())
>
> 5. Created /usr/lib/opkg so it can create its "lock" file
>
> 6. Created /etc/opkg.conf to include a reference to the old ipkg
> repository I'd like to use
> src snapshots http://www.acme.com/ipkg
> dest root /
>
> 7. But when I ran "/var/tmp/opkg/opkg-cl update", it says/does
> nothing. Am I
> missing something?
>
> Thank you.

Check that all the libraries are resolved with ldd (or if you don't
have that, play with /lib/ld-Uclibc.so --list). If that looks fine,
you will need to run opkg under strace to find out what it is doing.

-Graham

Fred

unread,
Apr 12, 2011, 11:27:24 AM4/12/11
to opkg-devel
On 12 avr, 01:25, Graham Gower <graham.go...@gmail.com> wrote:
> Check that all the libraries are resolved with ldd (or if you don't
> have that, play with /lib/ld-Uclibc.so --list). If that looks fine,
> you will need to run opkg under strace to find out what it is doing.

Thanks for the tip. The embedded appliance doesn't provide ldd/
readelf, but I'll try to cross-compile on Ubuntu.

Still, I don't find disabling Libcurl a good solution, as the opkg-cl
on the client will need to download opkg packages through the network.

Here's what I did to try and cross-compile opkg:
===============
CURL_LIBS=/usr/src/switchfin/build_ip01/uClinux-dist/staging/usr/lib/

cd /usr/src/opkg-read-only/

./configure --disable-gpg ac_cv_func_malloc_0_nonnull=yes --build=i686-
pc-linux --host=bfin-linux-uclibc target=bfin-linux-uclibc CC=bfin-
linux-uclibc-gcc AR=bfin-linux-uclibc-ar RANLIB=bfin-linux-uclibc-
ranlib CFLAGS="-O2 -Wall -I/usr/src/baps/uClinux-dist/linux-2.6.x/
include"
...
checking for bfin-linux-uclibc-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.20... yes
checking for CURL... configure: error: Package requirements (libcurl)
were not met:

No package 'libcurl' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables CURL_CFLAGS and
CURL_LIBS to avoid the need to call pkg-config. See the pkg-config man
page for more details.
================

Exporting CURL_CFLAGS and CURL_LIBS seems like the easier solution,
but Google didn't return information on how to configure those two
variables, and I'm obviously doing this wrong.

Does someone know?

Thank you.

Graham Gower

unread,
Apr 12, 2011, 6:23:02 PM4/12/11
to opkg-...@googlegroups.com
On 13 April 2011 00:57, Fred <frdt...@gmail.com> wrote:
> On 12 avr, 01:25, Graham Gower <graham.go...@gmail.com> wrote:
>> Check that all the libraries are resolved with ldd (or if you don't
>> have that, play with /lib/ld-Uclibc.so --list). If that looks fine,
>> you will need to run opkg under strace to find out what it is doing.
>
> Thanks for the tip. The embedded appliance doesn't provide ldd/
> readelf, but I'll try to cross-compile on Ubuntu.

The runtime linker should already provide this functionality. It
should reside at /lib/ld-uclibc.so or a simlilarly named binary,
perhaps with a version number. That can be executed to resolve
dynamically linked libraries. The glibc dynamic linker uses the --list
parameter to print them, I forget if uclibc provides the same
parameter.

>
> Still, I don't find disabling Libcurl a good solution, as the opkg-cl
> on the client will need to download opkg packages through the network.

Disabling curl doesn't mean that downloading of files is disabled, it
means that the wget binary will be invoked to perform this instead.

I suggest looking through your config.log to look for further info.

-Graham

Fred

unread,
Apr 13, 2011, 4:16:53 AM4/13/11
to opkg-devel
On 13 avr, 00:23, Graham Gower <graham.go...@gmail.com> wrote:
> The runtime linker should already provide this functionality. It should reside at /lib/ld-uclibc.so or a simlilarly named binary, perhaps with a version number.

Thanks for the tip, but there is no library that looks like that. But
it's OK, as scanelf from the pax-utils application (http://
distfiles.gentoo.org/distfiles/) provides a way to check library
dependencies.

> Disabling curl doesn't mean that downloading of files is disabled, it means that the wget binary will be invoked to perform this instead.

Thanks for the explanation.

I now have a working opkg-cl and could successfully work with a remote
ipkg repository.
Reply all
Reply to author
Forward
0 new messages