Xiaofan Chen
2018-07-10 12:05:02 UTC
Just tried to build libftdi under Visual C++ 2017 and it seems to have the
same problem as before. With the following patch, I can build the
ftdi dll/lib and ftdipp dll/lib.
Most of the examples need fixes as well. I can only build thee example,
find_all, find_all_pp and simple.
Patch is from the following. It may have some other fixed which
can be adopted.
https://github.com/svitalij/libftdi/commit/4ec6653df88a17b6232d9a5d6e85cc9441d3af85
***@ephwy-HP MINGW64 /c/work/libftdi/libftdi
$ git diff
diff --git a/src/ftdi_stream.c b/src/ftdi_stream.c
index 1dc46ea..158065a 100644
--- a/src/ftdi_stream.c
+++ b/src/ftdi_stream.c
@@ -48,6 +48,61 @@
#include "ftdi.h"
+#ifndef HAVE_GETTIMEOFDAY
+#ifdef _WIN32
+
+#include < time.h >
+#include <windows.h>
+
+#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
+#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
+#else
+#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
+#endif
+
+struct timezone
+{
+ int tz_minuteswest; /* minutes W of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ FILETIME ft;
+ unsigned __int64 tmpres = 0;
+ static int tzflag;
+
+ if (NULL != tv)
+ {
+ GetSystemTimeAsFileTime(&ft);
+
+ tmpres |= ft.dwHighDateTime;
+ tmpres <<= 32;
+ tmpres |= ft.dwLowDateTime;
+
+ /*converting file time to unix epoch*/
+ tmpres -= DELTA_EPOCH_IN_MICROSECS;
+ tmpres /= 10; /*convert into microseconds*/
+ tv->tv_sec = (long)(tmpres / 1000000UL);
+ tv->tv_usec = (long)(tmpres % 1000000UL);
+ }
+
+ if (NULL != tz)
+ {
+ if (!tzflag)
+ {
+ _tzset();
+ tzflag++;
+ }
+ tz->tz_minuteswest = _timezone / 60;
+ tz->tz_dsttime = _daylight;
+ }
+
+ return 0;
+}
+#endif // _WIN32
+#endif // HAVE_GETTIMEOFDAY
+
typedef struct
{
FTDIStreamCallback *callback;
3>------ Build started: Project: baud_test, Configuration: Release Win32 ------
2>async.c
2>c:\work\libftdi\libftdi\examples\async.c(24): fatal error C1083:
Cannot open include file: 'unistd.h': No such file or directory
3>baud_test.c
3>c:\work\libftdi\libftdi\examples\baud_test.c(32): fatal error C1083:
Cannot open include file: 'sys/time.h': No such file or directory
3>Done building project "baud_test.vcxproj" -- FAILED.
4>------ Build started: Project: bitbang, Configuration: Release Win32 ------
2>Done building project "async.vcxproj" -- FAILED.
5>------ Build started: Project: bitbang2, Configuration: Release Win32 ------
4>bitbang.c
4>c:\work\libftdi\libftdi\examples\bitbang.c(5): fatal error C1083:
Cannot open include file: 'unistd.h': No such file or directory
4>Done building project "bitbang.vcxproj" -- FAILED.
6>------ Build started: Project: bitbang_cbus, Configuration: Release
Win32 ------
6>bitbang_cbus.c
6>c:\work\libftdi\libftdi\examples\bitbang_cbus.c(33): fatal error
C1083: Cannot open include file: 'unistd.h': No such file or directory
7>------ Build started: Project: bitbang_ft2232, Configuration:
Release Win32 ------
6>Done building project "bitbang_cbus.vcxproj" -- FAILED.
8>------ Build started: Project: eeprom, Configuration: Release Win32 ------
8>eeprom.c
8>c:\work\libftdi\libftdi\examples\eeprom.c(10): fatal error C1083:
Cannot open include file: 'unistd.h': No such file or directory
8>Done building project "eeprom.vcxproj" -- FAILED.
9>------ Build started: Project: serial_test, Configuration: Release
Win32 ------
9>serial_test.c
9>c:\work\libftdi\libftdi\examples\serial_test.c(10): fatal error
C1083: Cannot open include file: 'unistd.h': No such file or directory
9>Done building project "serial_test.vcxproj" -- FAILED.
10>------ Build started: Project: stream_test, Configuration: Release
Win32 ------
7>bitbang_ft2232.c
7>c:\work\libftdi\libftdi\examples\bitbang_ft2232.c(13): fatal error
C1083: Cannot open include file: 'unistd.h': No such file or directory
7>Done building project "bitbang_ft2232.vcxproj" -- FAILED.
11>------ Skipped Build: Project: check, Configuration: Release Win32 ------
11>Project not selected to build for this solution configuration
12>------ Skipped Build: Project: dist, Configuration: Release Win32 ------
12>Project not selected to build for this solution configuration
10>stream_test.c
10>c:\work\libftdi\libftdi\examples\stream_test.c(22): fatal error
C1083: Cannot open include file: 'unistd.h': No such file or directory
10>Done building project "stream_test.vcxproj" -- FAILED.
same problem as before. With the following patch, I can build the
ftdi dll/lib and ftdipp dll/lib.
Most of the examples need fixes as well. I can only build thee example,
find_all, find_all_pp and simple.
Patch is from the following. It may have some other fixed which
can be adopted.
https://github.com/svitalij/libftdi/commit/4ec6653df88a17b6232d9a5d6e85cc9441d3af85
***@ephwy-HP MINGW64 /c/work/libftdi/libftdi
$ git diff
diff --git a/src/ftdi_stream.c b/src/ftdi_stream.c
index 1dc46ea..158065a 100644
--- a/src/ftdi_stream.c
+++ b/src/ftdi_stream.c
@@ -48,6 +48,61 @@
#include "ftdi.h"
+#ifndef HAVE_GETTIMEOFDAY
+#ifdef _WIN32
+
+#include < time.h >
+#include <windows.h>
+
+#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
+#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
+#else
+#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
+#endif
+
+struct timezone
+{
+ int tz_minuteswest; /* minutes W of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ FILETIME ft;
+ unsigned __int64 tmpres = 0;
+ static int tzflag;
+
+ if (NULL != tv)
+ {
+ GetSystemTimeAsFileTime(&ft);
+
+ tmpres |= ft.dwHighDateTime;
+ tmpres <<= 32;
+ tmpres |= ft.dwLowDateTime;
+
+ /*converting file time to unix epoch*/
+ tmpres -= DELTA_EPOCH_IN_MICROSECS;
+ tmpres /= 10; /*convert into microseconds*/
+ tv->tv_sec = (long)(tmpres / 1000000UL);
+ tv->tv_usec = (long)(tmpres % 1000000UL);
+ }
+
+ if (NULL != tz)
+ {
+ if (!tzflag)
+ {
+ _tzset();
+ tzflag++;
+ }
+ tz->tz_minuteswest = _timezone / 60;
+ tz->tz_dsttime = _daylight;
+ }
+
+ return 0;
+}
+#endif // _WIN32
+#endif // HAVE_GETTIMEOFDAY
+
typedef struct
{
FTDIStreamCallback *callback;
3>------ Build started: Project: baud_test, Configuration: Release Win32 ------
2>async.c
2>c:\work\libftdi\libftdi\examples\async.c(24): fatal error C1083:
Cannot open include file: 'unistd.h': No such file or directory
3>baud_test.c
3>c:\work\libftdi\libftdi\examples\baud_test.c(32): fatal error C1083:
Cannot open include file: 'sys/time.h': No such file or directory
3>Done building project "baud_test.vcxproj" -- FAILED.
4>------ Build started: Project: bitbang, Configuration: Release Win32 ------
2>Done building project "async.vcxproj" -- FAILED.
5>------ Build started: Project: bitbang2, Configuration: Release Win32 ------
4>bitbang.c
4>c:\work\libftdi\libftdi\examples\bitbang.c(5): fatal error C1083:
Cannot open include file: 'unistd.h': No such file or directory
4>Done building project "bitbang.vcxproj" -- FAILED.
6>------ Build started: Project: bitbang_cbus, Configuration: Release
Win32 ------
6>bitbang_cbus.c
6>c:\work\libftdi\libftdi\examples\bitbang_cbus.c(33): fatal error
C1083: Cannot open include file: 'unistd.h': No such file or directory
7>------ Build started: Project: bitbang_ft2232, Configuration:
Release Win32 ------
6>Done building project "bitbang_cbus.vcxproj" -- FAILED.
8>------ Build started: Project: eeprom, Configuration: Release Win32 ------
8>eeprom.c
8>c:\work\libftdi\libftdi\examples\eeprom.c(10): fatal error C1083:
Cannot open include file: 'unistd.h': No such file or directory
8>Done building project "eeprom.vcxproj" -- FAILED.
9>------ Build started: Project: serial_test, Configuration: Release
Win32 ------
9>serial_test.c
9>c:\work\libftdi\libftdi\examples\serial_test.c(10): fatal error
C1083: Cannot open include file: 'unistd.h': No such file or directory
9>Done building project "serial_test.vcxproj" -- FAILED.
10>------ Build started: Project: stream_test, Configuration: Release
Win32 ------
7>bitbang_ft2232.c
7>c:\work\libftdi\libftdi\examples\bitbang_ft2232.c(13): fatal error
C1083: Cannot open include file: 'unistd.h': No such file or directory
7>Done building project "bitbang_ft2232.vcxproj" -- FAILED.
11>------ Skipped Build: Project: check, Configuration: Release Win32 ------
11>Project not selected to build for this solution configuration
12>------ Skipped Build: Project: dist, Configuration: Release Win32 ------
12>Project not selected to build for this solution configuration
10>stream_test.c
10>c:\work\libftdi\libftdi\examples\stream_test.c(22): fatal error
C1083: Cannot open include file: 'unistd.h': No such file or directory
10>Done building project "stream_test.vcxproj" -- FAILED.
--
Xiaofan
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+***@developer.intra2net.com
Xiaofan
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+***@developer.intra2net.com