Forum Discussion
Altera_Forum
Honored Contributor
16 years agoIn case anyone else runs into this problem, I thought I'd share what I've figured out so far. This is probably stuff that an experianced windows programmer would know...but I'm not one of those :D
It appears that when you are making a windows application in MS visual studio you need to compile with "Pure MSIL Common Language Runtime Support (/clrpure)". However, you can force the compiler to use the decorated name you want. In this case, the DLL contains decorated names using __cdecl. The solution is go into the header file (my_jtag_atlanitic.h) and place __cdecl in from of all the function names. This will force the comiler to use the name that you want. so the original header file looked like this: typedef struct JTAGATLANTIC JTAGATLANTIC; JTAGATLANTIC * jtagatlantic_open(const char * chain, int device_index, int link_instance, const char * app_name); enum JATL_ERROR jtagatlantic_get_error(const char * * other_info); void jtagatlantic_close(JTAGATLANTIC * link); int jtagatlantic_write(JTAGATLANTIC * link, const char * data, unsigned int count); int jtagatlantic_flush(JTAGATLANTIC * link); int jtagatlantic_read(JTAGATLANTIC * link, char * buffer, unsigned int buffsize); this will result in lots of linker errors as specifided in a previous post. we can add the __cdecl modifier in front of the function names as follows: typedef struct JTAGATLANTIC JTAGATLANTIC; JTAGATLANTIC * __cdecl jtagatlantic_open(const char * chain, int device_index, int link_instance, const char * app_name); enum JATL_ERROR __cdecl jtagatlantic_get_error(const char * * other_info); void __cdecl jtagatlantic_close(JTAGATLANTIC * link); int __cdecl jtagatlantic_write(JTAGATLANTIC * link, const char * data, unsigned int count); int __cdecl jtagatlantic_flush(JTAGATLANTIC * link); int __cdecl jtagatlantic_read(JTAGATLANTIC * link, char * buffer, unsigned int buffsize); this modification makes the compiler use the names that match with what's in the DLL. I still get the following compiler warnings: warning LNK4248: unresolved typeref token (01000014) for 'JATL_ERROR'; image may not run warning LNK4248: unresolved typeref token (01000015) for 'JTAGATLANTIC'; image may not run these sound a little scary, but the application seems to run fine. The Jtag link is established when I bring it up. I've hit another problem that is crashing my program before I can actually send or receive data, but I don't think it's related to this. I'll update the forum when I get that far. I had to search around on MSDN for figure this out. I think this link had most of the explanation: http://msdn.microsoft.com/en-us/library/ms173253.aspx