I followed a combination of steps listed here and here to get zmq working on my NI cRIO-9047 running LabVIEW 2023 Q3.
ssh into cRIO using bash update the opkg repositories: opkg update
Install the following build tools: opkg install packagegroup-core-buildessential this step is only necessary for the target you’re using to compile the ZeroMQ libraries for.
Install ZeroMQ using: opkg install zeromq ; opkg install zeromq-staticdev this step is also required on targets that you are trying to run this library on.
Copy the cintools folder (this can be found in your LabVIEW install folder, I used the one in my Windows installation at C:\Program Files (x86)\National Instruments\LabVIEW 2023\cintools) to /usr/local/natinst/labview
Copy the labview-zmq directory to /usr/local/natinst/labview/vi.lib/addons (I had to create the /vi.lib/addons directories because they didn’t exist on the cRIO yet)
Edit the makefile located at: /usr/local/natinst/labview/vi.lib/addons/zeromq/lib/makefile to read:
# LINUX BUILD RULESelseLABVIEW=/usr/local/natinst/labviewLDFLAGS=-L$(LABVIEW)CFLAGS=-Wall-03-fpic-I/usr/local/natinst/labview/cintools-I/usr/includeLDLIBS=-lzmq-llvrtifdefDEBUGCFLAGS+=-DDEBUGendifall:lvzmq64.so# copy the product to the labview directory@cp$</usr/local/natinst/labview/vi.lib/addons/zeromqendif# Linux shared-library targetlvzmq64.so:$(SRC)$(CC)-shared-o$@$^$(CFLAGS)$(LDFLAGS)$(LDLIBS)
Edit line 634 of /usr/local/natinst/labview/vi.lib/addons/zeromq/lib/zmq_labview.c to be pthread_t thread; the lines before and after this section of code this looks like this:
Run make in the /usr/local/natinst/labview/vi.lib/addons/zeromq/lib/ directory.
Edited the VI zeromq.lvlib:zmq_libpath.vi to point to /usr/local/natinst/labview/vi.lib/addons/zeromq/lvzmq64.so when running on cRIO using Conditional Disable.
After all of these steps are followed, I’m getting the following error when I try to run zmq_ctx_create.vi on the cRIO:
I am not too familiar with realtime OS but to me it looks like you might be mixing 32 and 64 bit libraries?
In step 4. you copy files from C:\Program Files (x86)\National Instruments\LabVIEW 2023\cintools), this to me looks like 32 bit.
In step 6.2 you reference zeromq/lvzmq64.so, which looks like 64 bit.
My suggestion is to pick one or the other and make it consistent. (Perhaps install 64 bit LabVIEW and copy cintools from C:\Program Files\National Instruments\LabVIEW 2023\cintools.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Good catch. I just tried it again and made sure to copy both cintools and the zeromq folders from vi.lib from C:\Program Files\ instead of the 32 bit versions.
For some reason I got the following error during the build:
/usr/lib/gcc/x86_64-nilrt-linux/11.3.0/../../../../x86_64-nilrt-linux/bin/ld: cannot find -llvrt: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [makefile:51: lvzmq64.so] Error 1
I'm not sure why it's not finding llvrt, but if I remote that option from LDLIBS in the makefile, it builds without errors (I'm assuming the -llvrt flag is important to include though).
When I try to run zmq_ctx_create.vi, I still get the same error 13.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had the same exact issue, and ultimately found that this toolkit uses a "draft" feature of the zmq lib, which is not provided by opkg sources.
Instead, we need to build libzmq from source, and make sure to include the correct compilation flags. (This also required some additional dependencies to build successfully)
Here is a guide, most of which is copy and paste.
The only manual step is copying your C:\Program Files\National Instruments\LabVIEW 20XX\cintools directory to /usr/local/natinst/labview on your NILRT target.
Note: I am using "LabVIEW 2024 Q3" 64-bit, and recommend you also use a 64-bit install for this process. Although, it may work using the 32-bit cintools folder, I have not tested this.
Copy cintools to NILRT Target
Important! Copy the cintools folder from your host computer (this can be found in your LabVIEW install folder),
to the /usr/local/natinst/labview directory on the NILRT target.
This can be done using FTP/SFTP/SCP tools, such as WinSCP on Windows.
# install mercurial from https://git.kernel.org/torvalds/t/linux-6.12-rc5.tar.gz
wgethttps://repo.mercurial-scm.org/hg/archive/tip.zip
unziptip.zip
# change directory to the mercurial source code. The directory name may have a postfix appended to 'Mecurial-' so adjust the cd command accordinglycdMercurial-*/
makeinstall-homecd..
rm-rftiptip.zip
NORM Building and Install
Build NORM from source for NI-Linux since the package is not available via opkg manager:
# if the path '/usr/local/natinst/labview' has not been appended to '/etc/ld.so.conf.d/natinst_libs.conf', then append itif!grep-q'/usr/local/natinst/labview'/etc/ld.so.conf.d/natinst_libs.conf;thenecho'/usr/local/natinst/labview'>>/etc/ld.so.conf.d/natinst_libs.conf
# remove ldcache file to force ldconfig to rebuild the cacherm-f/etc/ld.so.cache
# call ldconfig to rebuild ldcacheldconfig
fi
Download, build, install ZeroMQ
Build ZeroMQ from source for NI-Linux since the Draft version is not available to install via opkg sources:
gitclone--recurse-submoduleshttps://github.com/zeromq/libzmq.git
cd./libzmq
exportUSE_NSS=yes
exportCURVE=libsodium
exportGSSAPI=enabled
exportPGM=enabled
exportNORM=enabled
exportTIPC=enabled
exportTLS=enabled
exportDRAFT=enabled
# export ADDRESS_SANITIZER=enabled# export POLLER=polling_method # Replace 'polling_method' with the desired poller method# export FORCE_98=enabled# export VMCI=enabled
./autogen.sh
./configure
make
makeinstall
cd..
rm-rf./libzmq
# remove ldcache file to force ldconfig to rebuild the cache
rm-f/etc/ld.so.cache&&ldconfig
Download, build, and install labview-zmq
cd/usr/local/natinst/labview/
hgclonehttp://hg.code.sf.net/p/labview-zmq/codezeromq
cd./zeromq/lib
sed-i's/#define LVALIGNMENT [14]/#define LVALIGNMENT 8/g'zmq_labview.c
sed-i's/pthread thread;/pthread_t thread;/g'zmq_labview.c
printf"# LVZMQ GNU-MAKE BUILD SCRIPT\n# for Linux targets\nSRC = zmq_labview.c\n\nLABVIEW = /usr/local/natinst/labview\nLDFLAGS = -L \$(LABVIEW)\nCFLAGS = -Wall -O3 -fpic -I \$(LABVIEW)/cintools -I \$(LABVIEW)\nLDLIBS = -lzmq -llvrt\nifdef DEBUG\n\tCFLAGS += -DDEBUG\nendif\n\nall : lvzmq64.so\n# copy the product to the labview directory\n\t@cp \$< \$(LABVIEW)\n\n# Linux shared-library target\nlvzmq64.so : \$(SRC)\n\t\$(CC) -shared -o \$@ \$^ \$(CFLAGS) \$(LDFLAGS) \$(LDLIBS)\n">makefile
make
rm-f/etc/ld.so.cache&&ldconfig
cd../..
rm-rf./zeromq
Edit zmq_libpath.vi
Edited zmq_libpath.vi in zeromq.lvlib to point to /usr/local/natinst/labview/lvzmq64.so when running on cRIO, by edditing the Conditional Disable structures accordingly.
Demo
See attached video of working demo, after performing the above steps on a fresh NI-LinuxRT VM install.
I followed a combination of steps listed here and here to get zmq working on my NI cRIO-9047 running LabVIEW 2023 Q3.
opkg update
opkg install packagegroup-core-buildessential
this step is only necessary for the target you’re using to compile the ZeroMQ libraries for.opkg install zeromq ; opkg install zeromq-staticdev
this step is also required on targets that you are trying to run this library on.pthread_t thread;
the lines before and after this section of code this looks like this:Run
make
in the /usr/local/natinst/labview/vi.lib/addons/zeromq/lib/ directory.Edited the VI zeromq.lvlib:zmq_libpath.vi to point to /usr/local/natinst/labview/vi.lib/addons/zeromq/lvzmq64.so when running on cRIO using Conditional Disable.
After all of these steps are followed, I’m getting the following error when I try to run zmq_ctx_create.vi on the cRIO:
Any suggestions of what to do to resolve this error?
Hi Zach,
I am not too familiar with realtime OS but to me it looks like you might be mixing 32 and 64 bit libraries?
In step 4. you copy files from C:\Program Files (x86)\National Instruments\LabVIEW 2023\cintools), this to me looks like 32 bit.
In step 6.2 you reference zeromq/lvzmq64.so, which looks like 64 bit.
My suggestion is to pick one or the other and make it consistent. (Perhaps install 64 bit LabVIEW and copy cintools from C:\Program Files\National Instruments\LabVIEW 2023\cintools.)
Good catch. I just tried it again and made sure to copy both
cintools
and thezeromq
folders from vi.lib from C:\Program Files\ instead of the 32 bit versions.For some reason I got the following error during the build:
I'm not sure why it's not finding llvrt, but if I remote that option from LDLIBS in the makefile, it builds without errors (I'm assuming the -llvrt flag is important to include though).
When I try to run zmq_ctx_create.vi, I still get the same error 13.
Hey Zach!
I had the same exact issue, and ultimately found that this toolkit uses a "draft" feature of the zmq lib, which is not provided by opkg sources.
Instead, we need to build libzmq from source, and make sure to include the correct compilation flags. (This also required some additional dependencies to build successfully)
Here is a guide, most of which is copy and paste.
The only manual step is copying your C:\Program Files\National Instruments\LabVIEW 20XX\cintools directory to /usr/local/natinst/labview on your NILRT target.
Copy cintools to NILRT Target
Install Necessary Dependencies
Mercurial Install
Needed for cloning code from SourceForge:
NORM Building and Install
Build NORM from source for NI-Linux since the package is not available via opkg manager:
ldconfig updates
Download, build, install ZeroMQ
Build ZeroMQ from source for NI-Linux since the Draft version is not available to install via opkg sources:
Download, build, and install labview-zmq
Edit zmq_libpath.vi
Edited zmq_libpath.vi in zeromq.lvlib to point to /usr/local/natinst/labview/lvzmq64.so when running on cRIO, by edditing the Conditional Disable structures accordingly.
Demo
See attached video of working demo, after performing the above steps on a fresh NI-LinuxRT VM install.
Last edit: Alexander Wolpe 2024-11-06
Automated Build & Install Script
Below is a script that will automate the entire process.
Assumptions
Script is run on your Windows host (containing the 64-bit LabVIEW installation you use for development)
Windows host can access your NI-L:inux RT target remotely, via ssh
Windows host has OpenSSH Client installed (up-to-date versions of Windows 11/10 should include this by default)
Procedure
Press Win+R to open a Run dialog box.
Type powershell.exe and press Enter.
Copy following code, and paste it into the PowerShell windows (Simply Right-Click anywhere within the PowerShell terminal window to Paste):
Last edit: Alexander Wolpe 2024-11-12