Microtelecom / libperseus-sdr

Perseus Software Defined Radio Control Library for Linux
http://microtelecom.it/perseus/
GNU Lesser General Public License v3.0
16 stars 7 forks source link

Windows compilation #3

Closed EdFuentetaja closed 9 years ago

EdFuentetaja commented 9 years ago

I tried to compile this code on Windows as well. Several issues here:

After struggling with MinGW I had to give up. I suspect there is an error on the configure.ac file but I'm not an expert on this toolchain. I finally used Visual Studio. Some sources need some modifications but the code compiles. Here I have an issue on execution. The test application stalls in the perseus_fx2_fpga_config_sr. This takes forever. I suspect the problem is with the libusb Windows implementation. On Linux the test application works fine. I hope this report is helpful. Thanks again for the excellent job.

amontefusco commented 9 years ago

Please, provide the errors you found when building with MinGW.

Probably you are the first person to attempt (other than me) to compile that on MinGW, so for sure some bug has to be ironed out.

Which release of Windows are you running on ? (W7, W8, 32 or 64 bits)

EdFuentetaja commented 9 years ago

Thanks for your interest. I gave it another try. This is a list of the issues I found and I how I fixed them, with the exception of the last one that made me give up and switch to Visual Studio:

I'm using W7 64 bits.

Called to ./bootstrap, got this error:

./bootstrap.sh: line 34: autoreconf: command not found

Checked that /mingw/bin is in the path:

echo $PATH .:/usr/local/bin:/mingw/bin:/bin:/c/Program Files (x86)/...

but / is pointing to C:\MinGW\msys\1.0:

mount C:\Users\XYZ\AppData\Local\Temp on /tmp type user (binmode,noumount) C:\MinGW\msys\1.0 on /usr type user (binmode,noumount) C:\MinGW\msys\1.0 on / type user (binmode,noumount) c: on /c type user (binmode,noumount)

... so lacking a better solution I copied everything inside C:\MinGW into C:\MinGW\msys\1.0 (with the exception of the msys folder). This seems to solve the problem. I think there is something wrong with this MinGW installer...

Next issue, on running ./configure:

configure: error: in `/c/work/temp/perseus/libperseus-sdr': configure: error: C compiler cannot create executables

Apparently solved indicating the target to 32bits (my machine is 64):

./configure --target=x86_32

Then realize I don't have libusb... Got it and try to compile. Here I got a compilation error:

io.c:2380:18: error: storage size of 'cur_ts' isn't known

It's exactly the same issue mentioned here: http://sourceforge.net/p/libusb/mailman/message/33200990/

Apparently solved commenting out a define in the threads_windows.h

// #if (!defined(HAVE_STRUCT_TIMESPEC) && !defined(_TIMESPEC_DEFINED))

define HAVE_STRUCT_TIMESPEC 1

define _TIMESPEC_DEFINED 1

struct timespec { long tv_sec; long tv_nsec; }; // #endif /* HAVE_STRUCT_TIMESPEC | _TIMESPEC_DEFINED */

OK, libusb complies and installs fine now. Back to perseus. Link error:

libtool: link: cannot determine absolute directory name of `../libusb-1.0.last/libusb/'

Given my lack of knowledge on what's going on inside configure.ac, I just went ahead and created those folders and copied libusb-1.0.a there.

The next error is the blocking one for me:

libtool: link: gcc -Wall -O3 -DGIT_REVISION=\"0.7.1\" -mno-ms-bitfields -I../libusb-1.0.last/ -DPTW32_STATIC_LIB -D__CLEANUP_C -g -O2 -I../libusb-1.0.last/ -o .libs/perseustest.exe perseustest.o perseus-sdr.o perseuserr.o perseusfx2.o perseus-in.o fpga_data.o -ldl -L../libusb-1.0.last/libusb/ -lusb-1.0c:/mingw/msys/1.0/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -ldl

On the configure.ac, it seems that the "dl" library applies to the linux case. It shouldn't be used on windows or mingw...?

Here is where I gave up and switched to Visual Studio, which was only slightly less painful.

Thank you again for your interest and I hope this might be useful to you.

amontefusco commented 9 years ago

Alas -ldl is correct, it has to be there, see my output below:

libtool: link: gcc -Wall -O3 -DGIT_REVISION=\"0.7.1\" -mno-ms-bitfields -I../libusb-1.0.last/ -DPTW32_STATIC_LIB -DCLEANUP_C -g -O 2 -I../libusb-1.0.last/ -o .libs/perseustest.exe perseustest.o perseus-sdr.o perseuserr.o perseusfx2.o perseus-in.o fpga_data.o -ld l -L../libusb-1.0.last/libusb/ /c/Users/andrew/libusb-1.0.last/libusb/.libs/libusb-1.0.dll.a -L/mingw/lib /bin/sh ./libtool --tag=CC --mode=link gcc -Wall -O3 -DGIT_REVISION=\"0.7.1\" -mno-ms-bitfields -I../libusb-1.0.last/ -DPTW32_STA TIC_LIB -D__CLEANUP_C -g -O2 -I../libusb-1.0.last/ -ldl -L../libusb-1.0.last/libusb/ -o perseustest_dyn.exe perseustest.o -lperse us-sdr -lusb-1.0 libtool: link: gcc -Wall -O3 -DGIT_REVISION=\"0.7.1\" -mno-ms-bitfields -I../libusb-1.0.last/ -DPTW32_STATIC_LIB -DCLEANUP_C -g -O 2 -I../libusb-1.0.last/ -o .libs/perseustest_dyn.exe perseustest.o -L../libusb-1.0.last/libusb/ /c/Users/andrew/libperseus_sdr-0.7. 1/.libs/libperseus-sdr.a -ldl /c/Users/andrew/libusb-1.0.last/libusb/.libs/libusb-1.0.dll.a -L/mingw/lib

so, I guess there is something that went wrong with the MinGW setup.

I suggest that now you have a working build environment, you start from the scratch, downloading the last released source from

https://github.com/amontefusco/libperseus-sdr/releases/download/v0.7.1/libperseus_sdr-0.7.1.tar.gz

next unzip, cd to the directory and issue a simple

./configure && make

if still faulty, please attach here your config.log as found in build directory.

For what concerns Visual Studio, if you manage to achieve the build, and you want to contribute, send me the configuration file, I will add to the project.

EdFuentetaja commented 9 years ago

Thank you for your support. I gave it another try. Yes, seems like dl is needed. I got it from https://github.com/dlfcn-win32/dlfcn-win32. Apparently the default MinGW installation doesn't include it. After doing a configure, make and make install of this lib I can compile the perseussdr with MingGW. I run the perseustest and everything seems OK!

Ultimately I'd like to compile this code with Visual Studio. As I mentioned on the first message, I was able to compile the code with VS but there is an error somewhere since the perseustest didn't clear. Since now I have a windows compilation that is working I can do some further debugging. I'll share with you how it goes.

Thanks again.