Skip to content

fieldrndservices/labpack-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LabPack-C: A LabVIEW-Friendly C library for encoding and decoding MessagePack data

About | Install | Build | API | Tests | License

What is LabPack-C?

The LabPack-C project is a LabVIEW-friendly C library for encoding and decoding MessagePack data. The library is intended to be used with the Call Library Function node. This provides MessagePack encoding and decoding functionality to LabVIEW as a Dynamic Link Library (DLL, Windows), Dynamic Library (Dylib, macOS), and/or Shared Object (SO, Linux).

Install

A single ZIP archive containing the pre-compiled/built shared libraries for all of the platforms listed in the Build section is provided with each release.

  1. Download the ZIP archive for the latest release. Note, this is not the source code ZIP file. The ZIP archive containing the pre-compiled/built shared libraries will be labeled: labpack-c_#.#.#.zip, where #.#.# is the version number for the release.
  2. Extract, or unzip, the ZIP archive.
  3. Copy and paste all or the platform-specific shared libraries to one of the following locations on disk:
Platform Destination
Windows C:\Windows\System32
macOS /usr/local/lib
Linux /usr/local/lib
NI Linux RT /usr/local/lib

Build

Ensure all of the following dependencies are installed and up-to-date before proceeding:

Windows

The Microsoft Visual C++ Build Tools 2017 should have installed a x64 Native Build Tools command prompt. Start the x64 Native Build Tools command prompt. This ensures the appropriate C compiler is available to CMake to build the library. Run the following commands to obtain a copy of the source code and build both the 32-bit and 64-bit DLLs with a Release configuration:

> git clone https://github.com/fieldrndservices/labpack-c.git LabPack-C
> cd LabPack-c
> build.bat

The DLLs will be available in the build32\bin and build64\bin folders.

macOS

Ensure the command-line tools for XCode have been installed along with git before proceeding. Start the Terminal.app. Run the following commands to obtain a copy of the source code from the repository and build the dynamic library (dylib):

$ git clone https://github.com/fieldrndservices/labpack-c.git LabPack-C
$ cd LabPack-C
$ mkdir build && cd build
$ cmake ..
$ cd ..
$ cmake --build build --config Release

The dynamic library (.dylib) will be available in the build/bin folder.

Linux

If running on Ubuntu or similar distribution, ensure the build-essential, cmake, and git packages are installed before proceeding. These can be installed with the following command from a terminal:

$ sudo apt-get install build-essential cmake git

Start a terminal, and run the following commands to obtain a copy of the source code from the repository and build the shared object (so):

$ git clone https://github.com/fieldrndservices/labpack-c.git
$ cd labpack-c
$ mkdir build && cd build
$ cmake ..
$ cd ..
$ cmake --build build --config Release

The shared object (.so) will be available in the build/bin folder.

NI Linux RT

NI provides a cross-compiler for their Real-Time (RT) Linux distribution. Before proceeding, download and install the C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition 2017. It is also best to review the Getting Stared with C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition guide for more general information about configuring the internal builder.

  1. Start NI Eclipse. A Workspace Launcher dialog may appear. Use the default.
  2. A welcome screen may appear after the application has loaded. Close the welcome screen.
  3. Right-click in the Project Explorer on the left and select Import from the context menu that appears. A new dialog will appear.
  4. Select Git->Projects from Git from the dialog that appears. Click the Next > button. A new page will appear.
  5. Select the Clone URI from the list that appears in the new page of the dialog. Click the Next > button. A new page will appear.
  6. Enter the URI for the git repository in the URI: field, i.e. https://github.com/fieldrndservices/labpack-c.git. The Host: and Repository path: fields will populate automatically. Click the Next > button. A new page will appear.
  7. Ensure only the master checkbox is checked in the Branch Selection page of the Import Projects from Git dialog. Click the Next > button. A new page will appear.
  8. Browse to the workspace directory for NI Eclipse to populate the Directory: field. Leave all other fields as the defaults. Click the Next > button. A new page will appear.
  9. Select the Import existing projects radio button from the options under the Wizard for project import section. Click the Next > button. A new page will appear.
  10. Click the Finish button. No changes are needed on the Import Projects page. A new labpack-c project should appear in the Project Explorer.
  11. Click the Build toolbar button (icon is a small hammer) to build the NI Linux RT x86_64-based shared object (so).
  12. Click the drop-down menu next to the Build toolbar button and select the ARM build configuration. This will build the NI Linux RT ARM-based shared object (so).

Note, steps 3-10 only need to be done once to setup the project. The liblabpack-rt.so will be located in the x86_64 folder under the project's root folder inside the Eclipse workspace folder, and the liblabpack-arm-rt.so will be located in the ARM folder under the project's root folder inside the Eclipse workspace folder.

Doxygen is used to build the Application Programming Interface (API) documentation. Ensure the latest version is installed then enter the following command from the root directory of the project to build the API docs:

$ mkdir -p build/docs/html
$ doxygen docs/Doxyfile

The output will be in the build/docs/html folder of the root directory of the project.

Tests

All of the tests are located in the tests folder. The tests are organized in "modules", where an executable is created that tests each source "module", i.e. writer, reader, etc. The tests are separated from the source, but the tests are built as part of build for the shared library. Each test executable is located in the bin\tests folder of the build directory and they can be run independently.

If the ctest, or make test on non-Windows systems, commands are used after building the tests to run the tests, then the ctest test runner framework is used to run the tests. This provides a very high level summary of the results of running all tests. Since the tests are organized into "modules" and suites, the ctest command only indicates that a test within a module and suite has failed. It does not indicate which test has failed. To investigate the failed test, the executable in the bin\tests folder for test module should be run. For example, if a test in the writer module failed, the ctest test runner will indicate the "writer" test has failed. The bin\tests\writer executable should then be run as a standalone application without the ctest test runner to obtain information about which test and assertion failed.

Windows

Start a terminal command prompt and navigate to the root folder of the project. Note, if following from the Build instructions, a command prompt should already be available at the root folder of the project. Enter the following commands to run the tests:

> ctest -C "Debug"

Or

> bin\reader
> bin\writer
> bin\status

macOS

Start the Terminal.app. Note, if following from the Build instructions, the Terminal.app has already been started and the present working directory (pwd) should already be the root folder of the project. Enter the following commands to run the tests:

$ ctest

Or,

$ bin/tests/reader
$ bin/tests/writer
$ bin/tests/status

Or,

$ make test

Linux

Start a terminal. Note, if following from the Build instructions, the terminal has already been started and the present working directory (pwd) should already be the root folder of the project. Enter the following commands to run the tests:

$ ctest

Or,

$ bin/tests/reader
$ bin/tests/writer
$ bin/tests/status

Or,

$ make test

License

See the LICENSE file for more information about licensing and copyright.