03-22-2019 05:27 PM
I have an application I would like to port to Linux. I have built and tested the program on a Windows machine and I have installed the CVI Linux module on a Linux box. When I build the app under Linux, however, it appears that the GPIB library is not being linked to, as I get "undefined reference" errors for ibrd, ibwrt, etc. Gpib.h is included in the source files and the user interface library functions don't seem to be a problem. Is there some reason why I would need to explicitly link the gpib function library and, if so, how would I do so? Thank you.
03-25-2019 11:51 AM
Can you provide a little more info on what versions of things you are using?
What versions of the GPIB drivers are installed on the Linux box?
What LabWindows/CVI version are you using?
03-25-2019 02:47 PM
I am using the CVI 2010 Runtime Module for Linux. GPIB drivers version is 2.5.1f0. The Windows sources include <gpib.h>, which is located in /usr/local/natinst/cvi2010 on the Linux machine. Since that didn't work, I included <ni488.h> from /usr/local/natinst/ni4882 instead of <gpib.h>, but I received the same errors when I built the project.
03-26-2019 10:50 AM
Interesting. Any particular reason for using CVI 2010 instead of a more recent version?
Are you using a Linux distro/version on the list of supported Linux Distributions for the Runtime Module for Linux?
Screenshots or a copy/paste of the includes portion of your code as well as the exact text of the errors might also be helpful in tracking down this bug.
03-26-2019 12:01 PM
I'm using 2010 because that's what we purchased several years ago. It looks like the latest version is 2013, so it doesn't appear that NI is doing much with CVI and Linux these days.
I have been able to resolve the gpib errors by explicitly linking the gpibapi library when running cvicc. cvicc apparently treats the gpib library as an "add on" (unlike some of the other CVI libraries, which are linked implicitly).
03-26-2019 03:27 PM - edited 03-26-2019 03:29 PM
There is one other problem I am having trying to build this project with cvicc. File "diagnostics.c" contains the following definitions (among others) at the top of the file:
double position;
int motor;
File IA_CounterTimer.h contains the lines:
extern int motor;
extern double position;
IA_CounterTimer.c <includes> IA_CounterTimer.h
MC1EN_ReadPosition (motor, &position) is called from IA_CounterTimer.c and this is just fine in Windows. When building the application under Linux, however, the linker gives an "undefined reference to position" error (it doesn't have a problem with "motor"). I can easily come up with a workaround for this error, but it doesn't make sense why the linker is complaining about an external double variable when it is completely happy with an int declared and defined in the same way (i.e., in a file external to the module from which the function is called).
04-01-2019 08:03 AM
You should really be using the 2013 version, I remember there were some serious bugs in the 2010 version. I don't know when the next version is due, but it's usually 4 years for Linux...
I'm not surprised that you need to use "cvicc -lgpib" to link.
As for your last problem, I can't tell, but it's just strange that the .c and .h file that share the definition and declaration of your variable have different names.