2.4 KiB
2.4 KiB
libicsneo C# Example
This is an example console application that uses the icsneocsharp library to control an Intrepid Control Systems hardware device.
Cloning
This will create a copy of the repository on your local machine.
Run:
git clone https://github.com/intrepidcs/libicsneo-examples --recursive
Alternatively, if you cloned without the --recursive flag, you must enter the libicsneo-examples folder and run the following:
git submodule update --recursive --init
If you haven't done this, third-party/libicsneo will be empty and you won't be able to build!
Windows using Visual Studio 2017+
Building the DLLs
icsneoc
First, we are going to build the icsneoc library into a .dll file that is used by the C# wrapper to access the library functions.
- Launch Visual Studio and open the
libicsneo-examplesfolder. - Choose
File->Open->Cmake... - Navigate to
third-party/libicsneoand select theCMakeLists.txtthere. - Visual Studio will process the CMake project.
- Select
Build->Rebuild All - Visual Studio will generate the
icsneoc.dllfile, which can then be found by selectingProject->Cmake Cache (x64-Debug Only)->Open in Explorer. If the file cannot be found, search inlibicsneo-examples/third-party/libicsneo/out/build/x64-Debugand double-check that the build succeeded in step 5. - Move the
icsneoc.dllfile to the/C/Windows/System32folder.
icsneocsharp
Next, we are going to build the wrapper functions into a .dll file that is used to access the library functions in C#.
- Launch a terminal window and change directories into
libicsneo-examples/libicsneocsharp-example, then create a build directory by runningmkdir -p build - Enter the build directory with
cd build - Run
cmake .. - Run
cmake --build . - The
icsneocsharp.dllfile will be generated inlibicsneo-examples/libicsneocsharp-example/build/Debug - Move the
icsneocsharp.dllfile to the/C/Windows/System32folder.
Building the example program
- Choose
File->Open->Project/Solution... - Navigate to
libicsneo-examples/libicsneocsharp-exampleand select thelibicsneocsharp-example.slnthere. - Visual Studio will process the project.
- Select
Build->Rebuild Solution - Click on the dropdown arrow attached to the green play button (labelled "Select Startup Item") and select
libicsneocsharp-example - Click on the green play button to run the example.