Problems compiling C in XCODE using VISA / NI

Hi,


I'm developing a program in C to communicate with my Tektronix oscilloscope. I inherited this project from a friend (who is currently incommunicado), so I can't talk to him about it.


Basically, my problem is that my program will not build due to a linker problem. I am using functions from the NI-VISA 5.4 package for OS X 10.8. However, the linker cannot seem to find the correct functions for my system:


Undefined symbols for architecture x86_64:

"_viClose", referenced from:

_setupVI in oscilloscope.o

_getData in oscilloscope.o

_closeInstr in oscilloscope.o

"_viOpen", referenced from:

_setupVI in oscilloscope.o

"_viOpenDefaultRM", referenced from:

_setupVI in oscilloscope.o

"_viRead", referenced from:

_setupVI in oscilloscope.o

_getData in oscilloscope.o

"_viStatusDesc", referenced from:

_setupVI in oscilloscope.o

_getData in oscilloscope.o

"_viWrite", referenced from:

_setupVI in oscilloscope.o

_getData in oscilloscope.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


These are all pretty basic VISA functions. I struggled in just including the correct header file, as

#include <visa.h>

didn't work. When I went to the verbose form, it worked:

#include "/Library/Frameworks/VISA.framework/Versions/A/Headers/visa.h"


However, then the problem started happening that I'm having now -- the object linker can't find the code for the VISA functions. I've tried changing build architctures from x86_64 to just x86, without avail. I'm currently building in i386 x86. I've also tried (under Build Phases -> Link Binary with Libraries) to link the VISA.framework to the project, but this simply gives the linker error "cannot find VISA".


I feel like I am missing something very obvious. I'm still operating under the notion that either NI-VISA did not install to the correct location, or that my build settings are incorrect.


Does anyone have any insight to lend? I've been searching through different forums for help for almost 2 days now, with no avail.

MacBook Pro, OS X Mountain Lion (10.8.4), XCODE 4.6.3 (4H1503)

Posted on Aug 8, 2013 6:18 AM

Reply
16 replies

Aug 8, 2013 7:30 AM in response to atucker-hs

Are you using Xcode or doing it from the command line?


You need to tell the compiler the library and where it is. In Xcode you would do this in the Build Phases window of the project under the Link Binary with Libraries area.


Just saw you say you tried this. Ar you sure you are setting the right path.


Where did you get the librsry from? Did you compile it on the Mac or was it compiled?

Aug 8, 2013 7:34 AM in response to Frank Caggiano

The path I tried while linking the binary was the VISA.framework folder in /Library/Frameworks


In Build Settings -> Search Paths I have also specified "/Library/Frameworks/VISA.framework" for both the fields "Framework Search Paths" and "Library Search Paths".


I also have told it to include .framework directories when recursively searching.


Thanks for the suggestion though.. just unfortunately I have tried it. I feel like I'm making a really stupid mistake somewhere.

Aug 8, 2013 8:44 AM in response to atucker-hs

My device communicates over USB. I've also tried compiling it in an x86 environment only (which should avoid the 64 bit problem entirely... right?) and in an x64 environment. Both give me the same errors for the respective environment.


I keep coming back to the notion that the code library might not be being installed in the correct place, but that should be fixed by Link Binary with Libraries...


Thanks for the idea though. Unfortunately I've already traversed that idea as well.

Aug 8, 2013 11:33 AM in response to xnav

That is a good point that I hadn't thought of--I didn't run any install operations before installing 5.4. I'll try uninstalling all of 5.4 (there's not an uninstaller; just a text file of files to delete) and then doing a clean install after a restart. I'll let you know how it goes.


As far as their included examples, I tried to compile them both when I had 5.3 and 5.4 installed. I used gcc from the command line, and there were tons of errors - far more than I have in my XCODE project.

Aug 8, 2013 11:40 AM in response to atucker-hs

atucker-hs wrote:


That is a good point that I hadn't thought of--I didn't run any install operations before installing 5.4. I'll try uninstalling all of 5.4 (there's not an uninstaller; just a text file of files to delete) and then doing a clean install after a restart. I'll let you know how it goes.


As far as their included examples, I tried to compile them both when I had 5.3 and 5.4 installed. I used gcc from the command line, and there were tons of errors - far more than I have in my XCODE project.

Did you try the Instruments/NI-VISA/Examples/C/ExamplesProject.pbproj?

Aug 8, 2013 12:30 PM in response to xnav

Final settings I ended up using:

Architectures

Architectures: $NATIVE_ARCH_ACTUAL

Build Active Architecture Only: No

Valid Architectures: i386 x86_64


Search Paths

no Framework Search Paths

no Library Search Paths


Build Phases

Link Binary With Libraries: VISA.framework


I think keeping /Library/Frameworks in the search paths is what was causing my problems when trying to Link Binary.


Thanks to xnav and Frank (had the right initial idea, which I had tried but just in the wrong manner).

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Problems compiling C in XCODE using VISA / NI

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.