VISA driver development setup - 64 bit compilation issues - Page 1
Forum section: electronics / testgear

author: DaJMasta
author_rank: Super Contributor
timestamp: November 08, 2016, 02:19:42 am
content: Figured I'd ask as I'm sure there's at least a few people around here who have worked with the IVI VISA drivers: what can I do to get my program to compile and run?I'm on windows 10 x64 using 64 bit Eclipse with the CDT package, have cygwin64 installed as my compiler, code is plain old C, and have tried using the provided headers/libraries from both NI's download package and direct from IVI. Trying to talk to a Fluke counter using a provided test program (have already verified that the equipment can talk to the computer over USB), but even with everything (I think) correctly imported into eclipse, on compile I run into several "relocation truncated to fit: R_X86_64_PC32 against" errors generated by the provided visa64 library.From what I've been able to gather, that means there's problems with the way it's handling memory allocation in the space beyond the normal 32 bit addressing space of old, but I can't put my finger on exactly what because I don't think I have source for any of this. I've looked around a bit and tried a couple of things, setting the "-mcmodel" flag to large didn't have any effect and the recommendation I've seen to use the flags "-Wl,--image-base -Wl,0x10000000", and while that does compile, launching the program ends in an immediate stack trace dump for a STATUS_ACCESS_VIOLATION.... so it effectively got me no where. I get the impression that compiler flags are likely the answer, but I don't know for sure.I'm not sure I know enough about the nuances of 64 bit addressing to interpret it much further, and I can't find the actual code that's giving me these issues, so I'm hoping someone's run into it before or has an idea what's going on. Alternatively, do you know of a 64 bit compiler that is known-working with the visa64 libraries? I can always give up and just reinstall a full set of stuff for 32 bit development, but that's an annoyance and I'm not yet defeated enough to try it.For reference, the program I'm trying to get running is example 4 from the Fluke PM6690 counter programming manual on page 4-11 and 4-12. I assume what they wrote should at least compile and run under normal circumstances :p

author: samofab
author_rank: Regular Contributor
timestamp: November 08, 2016, 08:00:54 pm
content: I would start by doublechecking whether that libraries that you're linking to are really 64 bit if you're compiling to 64 bit binary. To be frank, I always compiled my C VISA programs against 32bit library.Also start with really simple code.. just connect to VISA an close.. these three lines should be enough to check if your compilation environment is sane:ViSession defaultRM;viOpenDefaultRM(&defaultRM);viClose(defaultRM);

author: DaJMasta
author_rank: Super Contributor
timestamp: November 08, 2016, 10:38:42 pm
content: I appreciate the check, went in and made a new project with just that and got the same error (though fewer of them, since there were fewer referenced variables). Verified that the libraries were 64 bit pointing the linker to the visa32 library gave compatibility errors) Did some more messing with flags - changing the memory map start location will actually produce a different runtime error in some cases, but I couldn't get it working. Tried a few other general config things and did some more research on flags to no avail.Then I decided to give MinGW's 64 bit compiler a try.... downloaded, installed, new project with that 3 line stub in main..... compiles and runs without extra flags. It was pointed to the 64 bit libraries too, so even though the compiler will do 32/64 bit both, it's definitely making a 64 bit binary.So I suppose I'll just develop on that, I wonder what difference Cygwin has in its configuration that's preventing using the visa libraries. I still think it's likely correctable, but I suppose it's a good note to make in the event someone else runs into similar issues.