Fixing includes with Bazel - c++

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?.

Related

Homebrew installed Boost C++ 1.78.0 build issue with Xcode 13 iOS

I'm trying to get Boost C++ 1.78.0 working on an iOS project. There are several options out there, building from source, a static library, creating an xcframework, etc. This one focuses on build issues using the homebrew installed boost.
In full disclaimer this is my first time incorporating Objective-C & C++ in an iOS Xcode project, so it's entirely likely I'm doing something simple and obvious incorrectly.
The process is:
Install boost on the local machine
homebrew install boost
Add a header search to the correct homebrew include dir:
HEADER_SEARCH_PATHS = /opt/homebrew/include;
Depending on your installation this may be /usr/local/include. Just make sure #boost is found when you ls that directory.
Add a library search path:
LIBRARY_SEARCH_PATHS = /opt/homebrew/lib;
Include a boost header in an Objective-C file in the Xcode project such as:
#import <boost/property_tree/ptree.hpp>
After doing this, the build errors show up:
In file included from ~/Desktop/Boost Test/Boost Test/Boost.m:10:
In file included from /opt/homebrew/include/boost/property_tree/ptree.hpp:15:
In file included from /opt/homebrew/include/boost/property_tree/ptree_fwd.hpp:15:
/opt/homebrew/include/boost/optional/optional_fwd.hpp:21:1: error: unknown type name 'namespace'
namespace boost {
^
/opt/homebrew/include/boost/optional/optional_fwd.hpp:21:16: error: expected ';' after top level declarator
namespace boost {
^
;
In file included from ~/Desktop/Boost Test/Boost Test/Boost.m:10:
In file included from /opt/homebrew/include/boost/property_tree/ptree.hpp:15:
In file included from /opt/homebrew/include/boost/property_tree/ptree_fwd.hpp:16:
In file included from /opt/homebrew/include/boost/throw_exception.hpp:23:
/opt/homebrew/include/boost/exception/exception.hpp:10:10: fatal error: 'exception' file not found
#include <exception>
^~~~~~~~~~~
3 errors generated.
The list of errors changes/grows depending on which files you import and what they require. But it's a mixture of the same kind of stuff.
Lastly. Here's a super simple demo project that exhibits the issue: https://github.com/Archdoog/boost-xcode-build-failure. This should allow easy reference of the .pbxproj, etc.

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

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

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.

build with clang causes "'type_traits' file not found"

I try to build this with clang and CMake. But when I build, I get an error :
In file included from C:\Users\Yoann\Downloads\header-expander-master\src\BaseVisitor.cpp:1:
In file included from C:\Users\Yoann\Downloads\header-expander-master\src\BaseVisitor.h:4:
In file included from C:\LLVM\bin..\lib\clang\3.6.2../../../include\clang/AST/AST.h:18:
In file included from C:\LLVM\bin..\lib\clang\3.6.2../../../include\clang/AST/ASTContext.h:18:
In file included from C:\LLVM\bin..\lib\clang\3.6.2../../../include\clang/AST/ASTTypeTraits.h:20:
In file included from C:\LLVM\bin..\lib\clang\3.6.2../../../include\clang/AST/Decl.h:17:
In file included from C:\LLVM\bin..\lib\clang\3.6.2../../../include\clang/AST/APValue.h:17:
In file included from C:\LLVM\bin..\lib\clang\3.6.2../../../include\clang/Basic/LLVM.h:22:
In file included from C:\LLVM\bin..\lib\clang\3.6.2../../../include\llvm/Support/Casting.h:19:
C:\LLVM\bin..\lib\clang\3.6.2../../../include\llvm/Support/type_traits.h:17:10: fatal error: 'type_traits' file not found
type_traits is a stdlib++ file(I get mingw with stdlib++). How I can fix this?
Thanks

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.