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 12:32 PM in response to atucker-hs

atucker-hs wrote:


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"

Sorry, but there is no "verbose form", that's just incorrect 🙂


All you need to do is select your project in the project navigator. That will be the blue icon at the top. Then, you should see your project and targets listed in another navigator pane just to the right of that pane. Click the target icon under TARGETS. In the Summary tab, the second section is Linked frameworks and Libraries. Click the + button there. Click the Add Other button. Hold down shift-command-g and enter /Library/Frameworks. Select the VISA.framework (it may be a folder) and click the Open button.


Now click the Build Settings tab. Where you see "Basic" and "All", make sure "All" is selected. Search for "Framework". Locate "Framework Search Paths" and click the value column. In the window that pops up, click the + button. enter "/Library/Frameworks" (without quotes).


Now, do

#include <VISA/visa.h>

or

#include "VISA/visa.h"

either should work and it should build correctly.

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.