0

I'm trying to use ftd2xx.lib with lcc-win32 compiler but the linker fails. I used CDM v2.12.14 but also previous FTDI driverd give the same errors. I tried to compile on Windows XP and Windows7; same results.

If I link the static library I will get these kind of errors:

File ftd2xx.lib contains unknown section .text$mn.
.text section assumed
File ftd2xx.lib contains unknown section .data$r.
.data section assumed
.data$r: undefined reference to '??_7type_info@@6B@'
.text$mn: undefined reference to '__imp__SetupDiGetClassDevsA@16'
.text$mn: undefined reference to '__imp__SetupDiEnumDeviceInterfaces@20'

If I link the dynamic ftd2xx.lib (with ftd2xx.dll placed in the same dir of .exe file) I will get this:

Error e:\c\ftdi_cnt\main.c 11 undefined reference to __imp__FT_Open

(Note that main.c used for this test contains just a single FT_Open() call).

Is there anyone that was able to run ftd2xx.lib with lcc-win32 compiler or that is currently using lcc-win32 and can make a quick test? Here is the latest FTDI driver. Thank you.

J.Nathan
  • 1
  • 4
  • I don't know about Lcc-win32. I used that lib tons of times without problem with visual studio. – LPs Mar 10 '16 at 14:54
  • I begin to think D2XX needs a C++ compiler. Did anyone try with just a C compiler? – J.Nathan Mar 10 '16 at 17:03
  • [THIS]( http://xanthium.in/serial-communication-using-d2xx-library-and-ft232) suggests that is possible with c – LPs Mar 10 '16 at 18:27
  • Are you trying to link the original .lib files (which were probably for MSVC), or have you converted them to lcc-win32 library format? – Ian Abbott Mar 10 '16 at 18:52
  • The `ftd2xx.h` header file expects the `_WIN32` macro to be predefined when compiling on Windows. Does the Lcc-Win32 compiler do that? If not, you'll have to arrange for it to be defined before the header is included. – Ian Abbott Mar 10 '16 at 19:20
  • If using the static `ftd2xx.lib`, you need to arrange for the `FTD2XX_STATIC` macro to be defined before the `ftd2xx.h` header is included. – Ian Abbott Mar 10 '16 at 19:21
  • If using the dynamic `ftd2xx.lib`, note that the `ftd2xx.h` header file declares the functions with the Microsoft-specific `__declspec(dllimport)` specifier. If the Lcc-Win32 compiler does not understand that, it will probably throw up a load of errors while compiling. – Ian Abbott Mar 10 '16 at 19:25
  • @Ian Yes I placed #define FTD2XX_STATIC before #include "ftd2xx.h" and I'm quite sure that when I try to link the dynamic lib __declspec(dllimport) inside ftd2xx.h are enabled (instead of __declspec(dllexport)). I'm using the original libraries provided by FTDI, what could I do to convert them in a lcc-win32 compatible format? I tried with a pedump/buildlib treatment on the DLL but without success. – J.Nathan Mar 10 '16 at 20:22
  • @J.Nathan: I haven't used Lcc-win32 myself, but the little googling I did suggested you had to use `Utils --> Import foreign library`. – Ian Abbott Mar 11 '16 at 14:47

1 Answers1

0

Finally it works! Here is what I did:

1) Ian suggested I should use "Utils --> Import foreign library"; as a matter of fact this is the same of running from the command line:

pedump /EXP ftd2xx.lib >ftd2xx.exp
buildlib ftd2xx.exp ftd2xxy.lib

I've already tried that using for ftd2xx.lib the dynamic .lib but without success.

2) I ran pedump again, this time using the static .lib and I got a warning message about unknown dll name, so I edited the first line of ftd2xx.exp adding that name (ftd2xx.dll).

3) I defined FTD2XX_STATIC before including ftd2xx.h

4) I linked the new library ftd2xxy.lib

Note that you can't use "Utils --> Import foreign library" because you need to modify ftd2xx.exp before re-building the library.

I hope this could be helpful for others.

J.Nathan
  • 1
  • 4