I have installed MSYS2 along mingw64 on my win10 machine, I also Have downloaded the D2XX Drivers for linux from https://ftdichip.com/drivers/d2xx-drivers/ and I have extracted the archive and put the ftd2xx.h into C:\msys64\mingw64\include folder and libftd2xx.a into C:\msys64\mingw64\lib folder, Now I have written a simple program and try this command to compile the code gcc eeprom_example.c -o eeprom_example -lftd2xx
But I get these linker errors,
gcc eeprom_example.c -o eeprom_example -lftd2xx
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASIDES~1\AppData\Local\Temp\ccHdJs8k.o:eeprom_example:(.text+0xbc): undefined reference to `__imp_FT_EEPROM_Read'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASIDES~1\AppData\Local\Temp\ccHdJs8k.o:eeprom_example:(.text+0x205): undefined reference to `__imp_FT_EEPROM_Program'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASIDES~1\AppData\Local\Temp\ccHdJs8k.o:eeprom_example:(.text+0x26e): undefined reference to `__imp_FT_Open'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASIDES~1\AppData\Local\Temp\ccHdJs8k.o:eeprom_example:(.text+0x2d9): undefined reference to `__imp_FT_Close'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASIDES~1\AppData\Local\Temp\ccHdJs8k.o:eeprom_example:(.text+0x34a): undefined reference to `__imp_FT_Close'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASIDES~1\AppData\Local\Temp\ccHdJs8k.o:eeprom_example:(.text+0x364): undefined reference to `__imp_FT_Close'
collect2.exe: error: ld returned 1 exit status
What did I do wrong?
this is my actual code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ftd2xx.h"
#define EEPROM_SIZE 256
// Function to read EEPROM content
FT_STATUS readEEPROM(FT_HANDLE handle, uint8_t* eepromData, uint32_t eepromSize)
{
FT_STATUS status;
DWORD bytesRead;
char manufacturer[256];
char manufacturerId[256];
char description[256];
char serialNumber[256];
status = FT_EEPROM_Read(handle, eepromData, eepromSize, manufacturer, manufacturerId, description, serialNumber);
if (status != FT_OK)
{
printf("Failed to read EEPROM: %d\n", status);
return status;
}
printf("EEPROM content:\n");
for (int i = 0; i < eepromSize; i++)
{
printf("Address 0x%02X: 0x%02X\n", i, eepromData[i]);
}
return FT_OK;
}
// Function to write EEPROM content
FT_STATUS writeEEPROM(FT_HANDLE handle, uint8_t* eepromData, uint32_t eepromSize)
{
FT_STATUS status;
DWORD bytesWritten;
// Example usage of FT_EEPROM_Program
char manufacturer[] = "Manufacturer";
char manufacturerId[] = "ManufacturerId";
char description[] = "Description";
char serialNumber[] = "SerialNumber";
status = FT_EEPROM_Program(handle, eepromData, eepromSize, manufacturer, manufacturerId, description, serialNumber);
if (status != FT_OK)
{
printf("Failed to write EEPROM: %d\n", status);
return status;
}
printf("EEPROM content written successfully!\n");
return FT_OK;
}
int main()
{
FT_STATUS status;
FT_HANDLE handle;
uint8_t eepromData[EEPROM_SIZE];
// Initialize and open the FTDI device
status = FT_Open(0, &handle);
if (status != FT_OK)
{
printf("Failed to open FTDI device: %d\n", status);
return 1;
}
// Read EEPROM content
status = readEEPROM(handle, eepromData, EEPROM_SIZE);
if (status != FT_OK)
{
FT_Close(handle);
return 1;
}
// Modify EEPROM content (example: set all bytes to 0xFF)
for (int i = 0; i < EEPROM_SIZE; i++)
{
eepromData[i] = 0xFF;
}
// Write EEPROM content
status = writeEEPROM(handle, eepromData, EEPROM_SIZE);
if (status != FT_OK)
{
FT_Close(handle);
return 1;
}
// Close the FTDI device
FT_Close(handle);
return 0;
}