05-08-2023 02:06 PM
Hello I want to try reading and writing to an NI USB-8452 device in C.
I've downloaded the driver from https://www.ni.com/en-us/support/downloads/drivers/download.ni-845x-driver-software.html#460629
And I am in the example code located in C:\Users\Public\Documents\National Instruments\NI-845x\Examples\C\I2C\Basic\General I2C Read
But I am having issues with the line
#include "ni845x.h"
It seems that cmd/mingw/powershell cannot find the ni845x header file even after I set up the pathing in c_cpp_properties.json and tasks.json
it looks like I'm still having issues when trying to compile where the program cannot find that file even if it's properly linked.
I am not an expert on C but I have dug around online to where I'm positive I have the pathing correct as no errors flare up in VSC about the header file not being found anymore.
Sorry if this is confusing, TLDR;
Does anyone know how to get the ni845x driver to work in C for the example programs included in the installation of the library/driver
05-11-2023 03:35 AM
Yes it is confusing. First you talk about MingW/Powershell having a problem, then you talk abou VSC (I assume you mean Visual Studio Code) having no problem.
If you use MingW as compiler backend in Visual Studio Code, it will not know about the actual project settings just like that but needs to have the according include directories that you set in your project file have explicitly passed to it through the command line parameters.
I'm not normally using VSC but instead MSVC which doesn't let you easily replace the compiler backend but even there the actual invocation of the compiler backend actually gets ALL the project settings that apply to the current file to be processed to the compiler backend through the command line, this includes the -i parameters that indicate project specific include directories.
Editing JSON files directly to set these things should not be how VSC works, not even when you use the MingW backend.
Technically, even if you use VSC with the MingW backend you are not really using VC++ but rather Gcc/G++ here and the entire experience is for sure slightly different but it should still be possible.
05-11-2023 10:09 AM
Sorry about the confusing explanation.
Talking about minGW/PowerShell and VSCode, using cmd as my terminal, was to explain that I had tried using different sources to try and compile my program to see if it chalks up to one of those programs being used incorrectly.
tasks.json is set up to take the arguments like -I -L -l -g -o for VSCode to run the arguments necessary when compiling or running files.
c_cpp_preferences.json is set up so that VSCode can see the library linkages for intellisense.
The problem I am having is that I am pretty confident I have set up my tasks.json file correct, to where my -I -L -l -g -o all point to/contain the correct parameters but during compilation of the program it exits because it cannot find the ni845x.h or library, even though my paths point directly to the location.
Hopefully this clears up the air more than my original post.