Dingo_chaser Dingo_chaser - 11 months ago 81
C++ Question

Confirm location that .sublime-build is looking at (Sublime Text 3, C++) on Windows

I have a custom

file in Sublime Text 3 (ST3), where I have included folder that I want it to search for a c++ header file:

"cmd": ["g++", "$file_name", "-o", "${file_base_name}.exe", "-I C:/package/armadillo74002/include", "-L C:/package/armadillo74002/examples/lib_win64", "-lblas_win64_MT", "-llapack_win64_MT", "&&", "start", "cmd", "/c" , "$file_base_name"],
"selector": "source.c",
"working_dir": "${file_path}",
"shell": true

However, when I run the script:

#include <armadillo>

I get the following error:

headerex.cpp:2:21: fatal error: armadillo: No such file or directory

but I can check My Computer and see that the file exists in that directory. Why is it giving me this error? What can I change so that it can find the header file I am looking for?

Answer Source

I'm not familiar with all of the terminology, as my experience coding in C/C++ is somewhat limited, but it is my understanding that there are two types of #includes. The first type, where the header file name is enclosed in angle brackets < > (#include <stdio.h>, #include <string.h>, etc.), means you are including a header from the standard library.

The second type, where the included file is surrounded by double quotes " " (#include "Python.h", #include "myheader.h", etc.), is for including any other header whose location is specified in the Makefile or on the command line with the -I option (at least for gcc). Subdirectories can also be shown - for example, if you pass the -I/usr/local/include/mylib/include option, your include statement might be #include "x86_64/myheader.h" if there are subdirectories in the original directory.

Since armadillo doesn't sound like it's part of the standard lib, and you're passing its location on the command line, it might be a good idea to replace the angle brackets with double quotes and see if that does the trick.