1
Discussion - Software / libMPSSE: gcc returns an error
« on: August 10, 2018, 07:01:30 am »
Hi
I try to go first steps with libMPSSE for writing a simple SPI test for a FT232H, using gcc-installed with cygwin-under Netbeans.
Now, the gcc returns: "relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SPI_GetNumChannels'". The message points to the SPI_GetNumChannels()-call in following code (below):
The initialisation is the same like in code samples. I guess that the problem occures cause I'm working with a 64bit-OS (Win7), but I'm not sure about this. Sorry, but my experiance in C is quite poorly, in special of windows programming. The compiled sample programm works fine, but the code samples does not compile.
Does anyone have an idea how I get the code working?
Edit: Here is the complete output from Netbeans:
I try to go first steps with libMPSSE for writing a simple SPI test for a FT232H, using gcc-installed with cygwin-under Netbeans.
Now, the gcc returns: "relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SPI_GetNumChannels'". The message points to the SPI_GetNumChannels()-call in following code (below):
Code: [Select]
/******************************************************************************/
/* Include files */
/******************************************************************************/
/* Standard C libraries */
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/* OS specific libraries */
#define _WIN32
#ifdef _WIN32
#include<windows.h>
#endif
/* Include D2XX header*/
#include "ftd2xx.h"
/* Include libMPSSE header */
#include "libMPSSE_spi.h"
/******************************************************************************/
/* Macro and type defines */
/******************************************************************************/
/* Helper macros */
#define APP_CHECK_STATUS(exp) {if(exp!=FT_OK){printf("%s:%d:%s(): status(0x%x) \
!= FT_OK\n",__FILE__, __LINE__, __FUNCTION__,exp);exit(1);}else{;}};
#define CHECK_NULL(exp){if(exp==NULL){printf("%s:%d:%s(): NULL expression \
encountered \n",__FILE__, __LINE__, __FUNCTION__);exit(1);}else{;}};
/* Application specific macro definations */
#define SPI_DEVICE_BUFFER_SIZE 256
#define SPI_WRITE_COMPLETION_RETRY 10
#define START_ADDRESS_EEPROM 0x00 /*read/write start address inside the EEPROM*/
#define END_ADDRESS_EEPROM 0x10
#define RETRY_COUNT_EEPROM 10 /* number of retries if read/write fails */
#define CHANNEL_TO_OPEN 0 /*0 for first available channel, 1 for next... */
#define SPI_SLAVE_0 0
#define SPI_SLAVE_1 1
#define SPI_SLAVE_2 2
#define DATA_OFFSET 4
#define USE_WRITEREAD 0
/******************************************************************************/
/* Global variables */
/******************************************************************************/
static FT_HANDLE ftHandle;
static uint8 buffer[SPI_DEVICE_BUFFER_SIZE] = {0};
int main() {
FT_STATUS status = FT_OK;
FT_DEVICE_LIST_INFO_NODE devList = {0};
ChannelConfig channelConf = {0};
uint8 address = 0;
uint32 channels = 0;
uint16 data = 0;
uint8 i = 0;
uint8 latency = 255;
channelConf.ClockRate = 5000;
channelConf.LatencyTimer = latency;
channelConf.configOptions = SPI_CONFIG_OPTION_MODE0 | SPI_CONFIG_OPTION_CS_DBUS3; // | SPI_CONFIG_OPTION_CS_ACTIVELOW;
channelConf.Pin = 0x00000000; /*FinalVal-FinalDir-InitVal-InitDir (for dir 0=in, 1=out)*/
/* init library */
#ifdef _MSC_VER
Init_libMPSSE();
#endif
status = SPI_GetNumChannels(&channels); //<-- compiler-error here
//printf("Es sind %u Gerät(e) angeschlossen", channels);
return (EXIT_SUCCESS);
}
The initialisation is the same like in code samples. I guess that the problem occures cause I'm working with a 64bit-OS (Win7), but I'm not sure about this. Sorry, but my experiance in C is quite poorly, in special of windows programming. The compiled sample programm works fine, but the code samples does not compile.
Does anyone have an idea how I get the code working?
Edit: Here is the complete output from Netbeans:
Quote
cd 'I:\Documents\NetBeansProjects\GettingStartedMPSSE'
C:\cygwin\bin\make.exe -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/i/Documents/NetBeansProjects/GettingStartedMPSSE'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/gettingstartedmpsse.exe
make[2]: Entering directory '/cygdrive/i/Documents/NetBeansProjects/GettingStartedMPSSE'
mkdir -p dist/Debug/Cygwin-Windows
gcc -o dist/Debug/Cygwin-Windows/gettingstartedmpsse build/Debug/Cygwin-Windows/main.o
build/Debug/Cygwin-Windows/main.o: In function `main':
/cygdrive/i/Documents/NetBeansProjects/GettingStartedMPSSE/main.c:69: undefined reference to `SPI_GetNumChannels'
/cygdrive/i/Documents/NetBeansProjects/GettingStartedMPSSE/main.c:69:(.text+0x85): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SPI_GetNumChannels'
collect2: error: ld returned 1 exit status
make[2]: *** [nbproject/Makefile-Debug.mk:63: dist/Debug/Cygwin-Windows/gettingstartedmpsse.exe] Error 1
make[2]: Leaving directory '/cygdrive/i/Documents/NetBeansProjects/GettingStartedMPSSE'
make[1]: *** [nbproject/Makefile-Debug.mk:59: .build-conf] Error 2
make[1]: Leaving directory '/cygdrive/i/Documents/NetBeansProjects/GettingStartedMPSSE'
make: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)