Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I keep trying to compile this code but the compiler keeps saying "invalid conversion from const void* to void*". I put library and header files in the right directories. i'm not sure what i'm missing. here's the code

C++
#include<windows.h>
#include<ftd2xx.h>
#include<iostream>
using namespace std;
int main()
{
	FT_STATUS ftStatus;
	FT_HANDLE ftHandle;
	ftStatus = FT_OpenEx("FT232R USB UART",FT_OPEN_BY_DESCRIPTION,&ftHandle);
	if (ftStatus == FT_OK) 
	{
		cout << "it worked!" << endl;
	}
	else 
	{
		cout << "it didn't work! : ( " << endl;
	}
	return 0;
}


In the FTDI driver folder, there's also some .sys files and .dll files. I wasn't sure what to do with them so I copied them to the program folder.
Posted
Updated 3-Jul-12 17:05pm
v2

The first parameter of FT_OpenEx is of type LPVOID to pass different types (integer and char *) according to the second parameter. So you must use casting:
ftStatus = FT_OpenEx((LPVOID)"FT232R USB UART",FT_OPEN_BY_DESCRIPTION,&ftHandle);


If the FTDI DLL is present on your system (it is installed to the system folder when installing the device), all you need are the header file ftd2xx.h for including and the library ftd2xx.lib for linking.
 
Share this answer
 
The .lib files you have should also be part of the linker process; just add the .lib files into the VC project hierarchy (via Add Existing File)
 
Share this answer
 
Comments
Taylor H 3-Jul-12 21:05pm    
i tried making a project and doing that but it didn't work. originally i've been writing this as a single file. also, it will give me the object file but not the executable.
barneyman 3-Jul-12 21:11pm    
looks like it requires GCC - the .a file should be the static lib for using the dll, in which case the .a file should be on the link list too, using GCC
Taylor H 3-Jul-12 21:38pm    
okay, I'm gonna try that out right now! thanks for checking that out!
Taylor H 3-Jul-12 22:31pm    
the driver i downloaded doesn't have a .a file. the one i downloaded is called d2xx. also, the program compiles when i exclude ft_openex line
barneyman 3-Jul-12 23:06pm    
I just had a look at the windows download from 20824 - the ftdxx lib in the static/i386 dir exports that symbol

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900