Importing alternative header file in code oss on linux[Solved] - c++

I need an alternative header file to process.h for File * fprintf((FILE *)values,"%c %f\n ", Type, Code); commands which printing some values to a text file as column values
I am using Linux and Code OSS(vs code open source alternative) which gcc doesn't support process.h nativelly
I found subprocess.h and I need add library gcc but nor /usr/include nor working directory clones haven't worked still I am taking an error
vc1.cpp:16:10: fatal error: subprocess: No such file or directory
16 | #include <subprocess>
| ^~~~~~~~~~~~
compilation terminated.
Can I add additional header file on linux for Visual Studio Code and fix this problem.
Additionally, Editor suggest edit includepath settings but I think not raleted

Related

Fixing includes with Bazel

I am trying to fix includes with a local copy of openssl with bazel 5.0 on Mac using the clang compiler.
The file structure is as follows.
WORKSPACE
external
openssl
libcrypto.a
libssl.a
include
openssl
conf.h
.
.
.
Whenever I build openssl or anything dependent on it like https://github.com/nelhage/rules_boost. I get errors like the following.
In file included from external/com_github_nelhage_rules_boost/src/build_asio_ssl.cpp:1:
In file included from external/boost/boost/asio/ssl/impl/src.hpp:22:
In file included from external/boost/boost/asio/ssl/impl/context.ipp:24:
In file included from external/boost/boost/asio/ssl/context.hpp:23:
In file included from external/boost/boost/asio/ssl/context_base.hpp:19:
external/boost/boost/asio/ssl/detail/openssl_types.hpp:23:10: fatal error: 'openssl/conf.h' file not found
#include <openssl/conf.h>
or
In file included from contrib/epee/src/network_throttle-detail.cpp:58:
In file included from ./contrib/epee/include/net/abstract_tcp_server2.h:49:
In file included from external/boost/boost/asio/ssl.hpp:18:
In file included from external/boost/boost/asio/ssl/context.hpp:23:
In file included from external/boost/boost/asio/ssl/context_base.hpp:19:
In file included from external/boost/boost/asio/ssl/detail/openssl_types.hpp:23:
external/openssl/include/openssl/conf.h:19:11: fatal error: 'openssl/macros.h' file not found
# include <openssl/macros.h>
I am curious what other people have done to fix this sort of thing. I have tried adding includes = ["external/openssl/include/openssl"] and includes = ["include/openssl"] to the cc_library rule for openssl. I have also tried strip_include_prefix = "include/openssl" from C++ / Bazel: How to include angle <> bracket system headers?.

SOLVED - "fatal error: opencv: no such file or directory" in Sublime Text for c++

I'm not having any success with #include <opencv>, no matter what I try. [EDIT: I've also tried #include <opencv2> and #include <opencv4>, but there was no difference].
For context, I'm on Ubuntu 20.04, using Sublime Text 3, the latest version of OpenCV is installed on the system (at /usr/local/include/opencv4/opencv2), and I've tried something like six different build systems for cpp, including the default.
no matter what I try and how I fiddle with files, I always get the same error:
/home/user/Projects/Mind/CScript/Script.cpp:5:10: fatal error: opencv: No such file or directory
5 | #include <opencv>
| ^~~~~~~~
compilation terminated.
[Finished in 0.1s with exit code 1]
[shell_cmd: g++ "/home/user/Projects/Mind/CScript/Script.cpp" -o "/home/user/Projects/Mind/CScript/Script" && "/home/user/Projects/Mind/CScript/Script"]
[dir: /home/user/Projects/Mind/CScript]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]
I even tried to copy the whole opencv folder into the file path, but there was no change at all.
EDIT: The solution that worked was to paste the opencv2 folder from /usr/local/include/opencv4/ to /usr/local/include/. Apparently that additional folder wasn't supposed to be there.
An #include refers to a file, not a folder. A file so specified is looked for in the list of include paths.
-I /usr/local/include/opencv4/opencv2 adds that path to the list of include paths. The path, however, looks broken to me -- OpenCV has the legacy API in opencv/, and the updated API in opencv2/, but in either case there should be no opencv4/ in the path. (Double-checked with my APT.) Are you sure you did the OpenCV setup correctly?
The actual header's name is opencv2/opencv.hpp (note the .hpp at the end; generally, only the standard library's includes are without .hpp, all the third party libs I have seen so far use the .hpp extension).
Best practice is to leave the include path alone and write #include "opencv2/opencv.hpp" (with the subdirectory name) in your sources to avoid ambiguity.

Forcibly included header not found

I'm trying to set up precompiled headers in a large C++ project compiled with GCC 5.4.
There is a file "PrecompiledHeaders.h", which includes all the other relevant headers. I've added the compile flag -include PrecompiledHeaders.h, but when compiling, the header is not found:
cc1plus: fatal error: PrecompiledHeaders.h: No such file or directory
compilation terminated.
CMakeFiles/Project.dir/build.make:62: recipe for target 'CMakeFiles/Project.dir/NetworkGameState.cpp.o' failed
But I'm sure it exists, in the same directory as all other h and cpp files. What's more, manually adding #include "PrecompiledHeaders.h" to the top of "NetworkGameState.cpp" does not produce an error.
What could go wrong?
This is a CMake, out-of-source build, by the way.
It's likely an issue with the path. From the GCC 5.4 manual (emphasis mine):
-include file
Process file as if #include "file" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the #include "..." search chain as normal.
You need to either supply the full (relative or absolute) path to the header as the argument of the -include flag, or add its parent directory to the search chain using e.g. -I or -iquote.

include<apis/api1/api.h> throws No such file or directory

#include<apis/api1/api.h>
throws No such file or directory
i even tried moving api.h and api.cc to the main project directory and using
#include<api.h>
does the same thing even though it is in the exact same directory that the other classes use
i tried adding /apis/api1 to the compiler search path
that just crashes the compiler can someone tell me what to type into the compilers compilation line
#include <api.h>
is the way you include a system header. (That is, the header for a library installed on your system.) It does not search in the directory of the source file or in directories specified in -I command line arguments.
#include "api.h"
is the way you include your own headers. (But it will also search library header locations if it doesn't find the header locally.)

Fatal error: FlexLexer.h: No such file or directory

I created a simple Flex file to read and return tokens from a file. I generated the scanner file using the command flex -c++ scanner.l. When trying to compile the generated lex.yy.cc file I am getting the error as:
Fatal error: FlexLexer.h: No such file or directory
The include folder of flex contains the FlexLexer.h file. I also tried by copying the file to the same folder where lex.yy.cc resides. Still the error exists.
I am using Windows7.
How can I solve this problem. Thank You
The generated scanner uses the line:
#include <FlexLexer.h>
which means that the FlexLexer.h file will be searched for in system include directories. If you correctly install flex, the installation should put the FlexLexer.h file in some system include directory. If you just download the flex source and compile it without installing it, that won't work. And it might not work in the Windows environment either; I've never tried.
If you have no other alternative, and you're using gcc, you can tell gcc to use the include directory in the flex source tree as a system include directory using the command-line option -isystem /path/to/flex/include. There's almost certainly a VS2010 equivalent but I have no idea what it is.