mingw32

Peter Stuge peter at stuge.se
Sat Jan 26 04:44:56 UTC 2013


Leif Asbrink wrote:
> Attempts to link librtlsdr and libusb-1.0 with my project

Please note that libusbx is not libusb. I'm the maintainer of libusb
at libusb.org and libusbx is a fork with some good additions but more
notably an overwhelming amount of questionable practises and changes,
by basically one developer who refuses to work with me. (He banned me
from the libusbx mailing list when I wrote that some of his code
which is both in libusb and libusbx had a bug.)

While I do pay attention to what happens in libusbx I don't know
exactly what the state is of that code. I haven't tested libusbx-1.0.14
in a while, and in particular not on Windows, where libusbx has crazy
changes compared to the original libusb-1.0 from libusb.org. (That's
the platform the main developer works on.)

I know of others who have had strange issues with libusbx-1.0.14,
while the latest libusb.git source code from libusb.org instead
worked as expected.

Please grab the latest code from http://git.libusb.org/libusb.git
and see if it works any better.


> BUT if I try to change frequency or gain Windows crashes. Also
> if I try to exit. It seems one must not call anything
> else in libusb-1.0 after having started read.

That would be a bug in the implementation. The API design very much
allows mixing sync and async transfers, and it works fine in
libusb-1.0.


> I have used mingw32, the standard install under Ubuntu.

Ok.


> I was unable to use the configure script

This is a HUGE alarm bell for me. Especially if you are just starting
out with learning cross-compiling it is critical that you make things
work exactly the way they are supposed to, or you are just setting
yourself up for endless unneccessary trouble.

If you tried to use configure and it did not work then why don't you
show what went wrong?

Please show the configure command that you ran, along with the
complete output that it produced. I assume that there were some
errors in the end, make sure to include those of course, and ideally
also attach the complete config.log file. Feel free to send that in
an email directly to me if the mailing list thinks that the
attachments are too large. Make sure to send the log file as plain
text, ie. either inline in the email, or attached with text/plain
MIME type.


> but made a simple script to compile with
> /usr/bin/i586-mingw32msvc-gcc
> and then create the library and install like this:
> 
> /usr/bin/i586-mingw32msvc-ar rc librtlsdr.a librtlsdr.o tuner_tuner_fc0013.o tuner_fc2580.o tuner_r820t.o
> /usr/bin/i586-mingw32msvc-ranlib librtlsdr.a
> cp librtlsdr.a /usr/i586-mingw32msvc/lib

It's a bad idea to store librtlsdr in the toolchain lib dir. The
correct approach is to use a so-called prefix directory, which as
it happens is taken caren of automatically by the configure script.


> What can I do to fix the problem?

I'm happy to help you sort things out with libusb-1.0, but you'll
have to work with the code from libusb.org.

configuring and building libusb with that ubuntu cross-compiler
should work without any issues..

git clone git://git.libusb.org/libusb.git && \
  cd libusb && \
  ./autogen.sh --host=i586-mingw32msvc --prefix=$(pwd)/../winlibs && \
  make install && \
  cd .. && \
git clone git://git.osmocom.org/rtl-sdr && \
  cd rtl-sdr && \
  autoreconf -fi && \
  PKG_CONFIG_LIBDIR=$(pwd)/../winlibs/lib/pkgconfig \
    ./configure --host=i586-mingw32msvc --prefix=$(pwd)/../winlibs && \
  make install && \
  cd .. && \
ls -l winlibs/bin winlibs/lib

..builds libusb and rtl-sdr using the cross-compiler and installs the
built files into the winlibs/ directory wherever you copypaste the
above commands.

But, I don't know if the rtl-sdr configure.ac works so well for
cross-compiling for Windows. The last time I tried to cross-compile
rtl-sdr for Windows I used cmake, and I had to work around several
issues to make that work.

If you want to focus on the USB communication then you can of course
continue bypassing the build system for rtl-sdr, but if it has
actually been fixed since I tried to cross-compile then you should
really use it.

The libusb that gets built above includes very verbose debug logging,
and will output lots of lines of useful information when you run a
program which uses it. When there are no more bugs to deal with you
will rebuild libusb without that debug logging:

cd libusb && \
  ./configure --host=i586-mingw32msvc --prefix=../winlibs \
    --disable-debug-log && \
  make install && \
  cd ..

I hope you already see the pattern for how configure works.


If something doesn't work, please send complete information to get a
useful response.


//Peter




More information about the osmocom-sdr mailing list