libftdi Archives

Subject: Re: MSVC build of libftdi git

From: Xiaofan Chen <xiaofanc@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 30 Aug 2011 17:59:18 +0800
On Fri, Aug 26, 2011 at 10:42 PM, Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
> On Fri, Aug 26, 2011 at 10:30 PM, Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
>> I remember Michael Plante mentioned that libfti was able to be built under
>> Visual Studio. So out of curiosity, I used CMake to generate the VS2010
>> project file (32bit) and indeed the library build is okay. Only 2
>> examples can be built though.
>>
>> The generated dll file is ftdi.dll and the generated lib file is
>> ftdi.lib but I think the proper name is actually libftdi.dll
>> and libftdi.lib (for MSVC).
>>
>> It might be good to fix the MSVC build as well for the
>> examples.
>
> For libusb-1.0, the library build failed. Maybe this has something
> to do with the calling convention of libusb-1.0 (default is stdcall).
>
> Error   372     error C2440: 'function' : cannot convert from 'void (__cdecl
> *)(libusb_transfer *)' to 'libusb_transfer_cb_fn'
> D:\work\libftdi\libftdi-1.0\src\ftdi.c  1417    1       ftdi-static
> Error   376     error C2440: 'function' : cannot convert from 'void (__cdecl
> *)(libusb_transfer *)' to 'libusb_transfer_cb_fn'
> D:\work\libftdi\libftdi-1.0\src\ftdi.c  1500    1       ftdi-static
> Error   806     error C2440: 'function' : cannot convert from 'void (__cdecl
> *)(libusb_transfer *)' to 'libusb_transfer_cb_fn'
> D:\work\libftdi\libftdi-1.0\src\ftdi_stream.c   200     1       ftdi-static
>


Declaring these callback functions as stdcall works. Add LIBUSB_CALL
to the function definitions solved the above problems.

Then google helped me to find out the MSVC replacement of
gettimeofday() here.
http://stackoverflow.com/questions/2494356/how-to-use-gettimeofday-or-something-equivalent-with-visual-studio-c-2008

After that, I can build libftdi-1.0 with MSVC2010 (the dll and static lib
and two examples). The two examples seem to work as well.

Maybe it is worth to support MSVC (say 2010) in libftdi since
MSVC is the most popular C compiler under Windows.

-- 
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx

Current Thread