I have spent many hours on this basic issue and can’t figure it out. I have added a directory to our C++ project that has both src and include (to support a camera). for the life of me, I can’t get VS to compile a CPP with a .h from the include directory.
I’d love some basic steps on how to do this. In a normal world, adding a “-I” with dir to the makefile would do the job.
I have tried many variations of adding directories to c_cpp_properties.json and NONE work. Compilation still can’t find the include dir.
“configurations”: [
{
“name”: “Win32”,
“includePath”: [
“${workspaceFolder}/**”,
“C:/Users/Programming/Documents/MergeLEDCommandTestCode/src/pixy2/src/common/inc”,
“${workspaceRoot}/src/pixy2/src/common/inc”,
“C:/Users/Programming/Documents/MergeLEDCommandTestCode/src/pixy2/src/common/inc”,
“src/pixy2/src/common/inc”,
“C:/Users/Public/frc2019/roborio/arm-frc2019-linux-gnueabi/usr/include”,
“C:/Users/Public/frc2019/roborio/arm-frc2019-linux-gnueabi/usr/include/linux”,
“C:/Users/Programming/Documents/MergeLEDCommandTestCode/src/pixy2/src/host/windows”
I found one post that says that the c_cpp_properties.json file is not needed and can be deleted:
If that is the case, where do I put my include directory in the VS configuration?
thanks !!
If I understand your question properly, you have created a class in a header(h/hpp) and source (cpp) and are confused how to use them in your robot class?
Thanks for the responses! All right, we’ve made some progress we can share (user redmonke and bothacker are on the same team #509 laptop).
Let us clarify what we are doing. We already had the baseline robot image building and working. We successfully added some Commands and a Command Group per the WPIlib guidelines. Now we are integrating the pixy2 camera code and this phase is what gave us the difficulty. We did not want to dump all the pixy2 support code into the main directory and wanted to keep the bulk of the pixy2 directory provided from their git repo as-is.
Here are some general steps that may help others …
(1) We made a pixy2 source directory and put one of the main pixy2 files into it. VS was good with understanding that this dir contained files that needed to be compiled in. We used right-click “New Folder” to add this.
(2) We used intellisense to add the linux directories for the base C++ dependencies like stddef.h. Hover over the lightbulb, select add to the properties file. VS put these into the c_cpp_properties.json file. HOWEVER, our attempts at adding the pixy2 include directories manually to this json file did not work, a painful lesson.
(3) As Jaci suggested, we found that adding the pixy2 include directories to build.gradle got them into the system build. Many hours needed to figure this out!! Now we can keep the pixy2 directory structure from git as-is, a big win.
In theory these steps could be generalized to add other 3rd party code that is not packaged nicely.
We are past the compilation phase and now working on the link phase. We now have an external dependency on the USB library to deal with.
Here is a link we found useful to understand some of the Intellisense rules and c_cpp_properties.json file content: