How can I include the Jambase file to my build? - boost-build

I'm trying to setup a simple bjam build example, where I use the SubDir rule in my top-level Jamroot.jam file:
SubDir TOP ;
exe main : main.cpp ;
I'm using boost_1_58_0 and when I leave out the SubDir directive, the build works fine.
But when I try to use SubDir, bjam claims that the rule is unknown...although I see that the Jambase file gets parsed:
dirkb#wks91:bjam_try$ BOOST_BUILD_ROOT=/home/dirkb/snaps/git/boost_1_58_0 BOOST_ROOT=/home/dirkb/snaps/git/boost_1_58_0 /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/engine/bin.linuxx86_64/b2 -f Jambase --debug-loading --debug-configuration
Parsing file: Jambase
notice: found boost-build.jam at /home/dirkb/snaps/git/boost_1_58_0/boost-build.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/boost-build.jam
notice: loading Boost.Build from /home/dirkb/snaps/git/boost_1_58_0/tools/build/src
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/bootstrap.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/bootstrap.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/modules.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/modules.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/option.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build-system.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/build-request.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/class.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/numbers.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/errors.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/sequence.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/assert.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/set.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/regex.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/feature.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/indirect.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/utility.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/property.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/path.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/string.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/container.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/builtin.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/alias.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/project.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/print.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/scanner.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/property-set.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/virtual-target.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/type.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/generators.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/os.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/common.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/toolset.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/order.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/targets.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/stage.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/register.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/asm.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/cpp.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/exe.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/html.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/lib.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/obj.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/objc.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/preprocessed.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/qt.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/rsp.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/symlink.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/message.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/convert.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/generate.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/configure.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/config-cache.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/make.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/version.jam
Initializing project 'test-config'
Assigned project target object(project-target)#62 to 'test-config'
Initializing project 'site-config'
Assigned project target object(project-target)#64 to 'site-config'
notice: Searching '/etc' '/home/dirkb' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src' '/usr/share/boost-build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/contrib' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/.' for site-config configuration file 'site-config.jam'.
notice: Configuration file 'site-config.jam' not found in '/etc' '/home/dirkb' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src' '/usr/share/boost-build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/contrib' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/.'.
Initializing project 'user-config'
Assigned project target object(project-target)#66 to 'user-config'
notice: Searching '/home/dirkb' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src' '/usr/share/boost-build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/contrib' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/.' for user-config configuration file 'user-config.jam'.
notice: Configuration file 'user-config.jam' not found in '/home/dirkb' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src' '/usr/share/boost-build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/contrib' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/.'.
Loading Jamfile at '.'
Initializing project 'Jamfile</disk2/stuff/dirkb/snaps/git/bjam_try>'
Assigned project target object(project-target)#68 to 'Jamfile</disk2/stuff/dirkb/snaps/git/bjam_try>'
Parsing file: Jamroot.jam
Jamroot.jam:1: in modules.load
ERROR: rule "SubDir" unknown in module "Jamfile</disk2/stuff/dirkb/snaps/git/bjam_try>".
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/project.jam:325: in load-jamfile
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/project.jam:64: in load
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/project.jam:145: in project.find
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build-system.jam:535: in load
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/modules.jam:289: in import
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/bootstrap.jam:139: in boost-build
/home/dirkb/snaps/git/boost_1_58_0/boost-build.jam:17: in module scope
dirkb#wks91:bjam_try$
The Jambase file, and a simple Jamrules, exist at the top-level of my toy project. When I leave out the "-f Jambase" option, bjam picks the internal Jambase definition (+) but yields the same result...SubDir is unknown.
When I start bjam with the option "-d 12" I see that the SubDir rule from the Jambase gets properly scanned, but somehow it's not correctly bound, defined or whatever bjam usually does to make methods/rules "usable".
As you can probably see from the used paths, I have only bootstrapped b2 so boost isn't properly installed yet. For debugging, I also patched its sources a little bit, that's where the "Parsing file..." messages come from.
How can I properly "inject" the rule definitions from the Jambase file, such that they are known while parsing Jamfiles?

TL;DR: If your project contains Jamfiles that refer to definitions like SubDir from the Jambase file, don't bother trying to use bjam/b2. Use ft-jam instead!
Long answer with some more background info:
At work I tried to build an old software package (Ingres DBMS 10.1) from
source over two weeks. It contained Jamfile and Jamrules files
in its tree structure, so I concluded that I would have to use bjam/b2
to get things going. The project's documentation wasn't specific enough
about this point as it turned out.
I had one major problem, the Jamfiles would use a lot of definitions
from the "Jambase" file, like "SubDir" a.s.o. Everytime I started the
build, I would get the error "unknown rule", as you can also see in the
question.
I finally decided to give an older Jam version a try, and voila: with
ft-jam v2.5.2 the project compiled flawlessly without any further ado. Yay!
So, basically everything was fine now and I could use ft-jam for my
purposes. But I still wondered whether I could also use bjam/b2 for the
compile. What is the purpose of the internal Jambase definition ("+"
file) and the "-f" option in bjam? Is it only for bootstrapping b2
itself, or can I use it while running b2? If yes, how do I activate it?
In the end, I wrote to the boost-build mailing list and got the following answer:
b2 is not a drop-in replacement for Perforce Jam. Using ft-jam is the
correct option.
The current Jambase is only used for bootstrapping Boost.Build. Older
versions of b2 had a copy of the original Jambase which would be
activated if the executable was named something other than b2/bjam.
Even so, I don't recommend using it as it was completely unmaintained.
Link to mail thread

Related

How to get Rcpp to include the right header file path

I was trying to run a simple testing C++ file in my R package development directory with Rcpp located at say the directory "my_R_package_dir/src/my_file_location.cpp":
#include <Rcpp.h>
// [[Rcpp::export]]
int plusone() {
return 1 + 1;
}
But when running Rcpp::sourceCpp("src/my_file_location.cpp") the R console gives the following warning:
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/myself/my_R_package_dir/src/../inst/include": file not found
The function exported plusone() did work, but I can see clearly that its for some reason trying to access a non-existent file named "include" in the "inst" directory which I do have. I'm guessing it wants to access the Rcpp.h file but I probably need to somehow indicate it the path to point at? How do I do that?
P.S. This also causes the package build to fail and part of the message also indicates that theres no such file or directory Rcpp.h.
I thought I needed a Makevars.win and Makevars file, and I put them both into src and they look like this:
PKG_CPPFLAGS=`Rscript -e 'Rcpp:::CxxFlags()'`
PKG_LIBS=`Rscript -e 'Rcpp:::LdFlags()'`
CC=C:\msys64\mingw64\bin\g++.exe
CXX=C:\msys64\mingw64\bin\gcc.exe
But with no avail. I am on a windows device with Rtools 4.3, gcc, and g++.

Protoc Output Directory Issue - No Such File or Directory

I recently finished the basic tutorial for C++ here and wanted to set up a project based on the proto files from here. I followed a similar directory structure as the tutorial and changed up the CMakeLists.txt file to accommodate the new files.
I'm currently trying to just compile the manager.proto file. I was able to compile the file and get my server/client files, however the files are being outputted within cmake/build/minknow_api rather than the expected cmake/build folder. This meant the make command would return the error:
clang: error: no such file or directory: '/Users/name/Documents/grpc/examples/cpp/minknow_api/cmake/build/manager.grpc.pb.cc'
clang: error: no input files
I read that it was because protoc outputs based on the imports of the proto file, i.e the file comes with import minknow_api/device.proto for instance. I copied the files from within the cmake/build/minknow_api into cmake/build/ and reran make and it seemed to work, however, the C++ file imports as expected are searching within a minknow_api directory, meaning I'd have to manually edit these imports to look within the current directory instead of to then compile successfully.
I've tried experimenting with trying to get rid of the minknow_api from the proto imports, however had no luck and only got more import issues during compilation. It seems some files have the same names for messages etc, which means I had to keep the minknow.somename as the package so I can thus distinguish in the files which imported values I wanted to access. I've also tried moving files into their own directories like instance.proto which has package minknow.instance would go inside of instance directory, but still no luck.
I was wondering if anyone could figure out how to get rid of the minknow_api out of my proto imports properly so that I won't get these import and output directory issues down the track?

Developed clangtool does not find headers outside source tree (runtime)

I'm developing a clang based tool with which I process the AST generated by clang. Right now I'm developing inside the llvm-project tree (I cloned the whole repository) as mentioned in this tutorial. I've created the CMakeLists.txt as mentioned and I executed the cmake command as seen in the tutorial.
The project compiles and the output binary file is located in the build/bin with the other binaries inside the llvm-project source tree. When I execute my binary from the build/bin, upon parsing the input c++ file, everything goes well.
But, when I copy the generated binary to my home directory or anywhere else and I execute it, upon the parsing, it does not manage to find the standard headers for instance stddef.h:
/usr/include/stdlib.h:32:10: fatal error: 'stddef.h' file not found
My question is why it can find the header in one place and not in another? In one of the forum I found this: Some header files (stddef.h, stdarg.h, and others) are shipped with Clang — these are called builtin includes. Clang searches for them in a directory relative to the location of the clang binary.
I've checked the build directory, in which the binary is located originally, and it contains lib/clang/include directory in which there is also the file stddef.h. Is it possible that by executing in place the binary, it founds this path and when I copy it somewhere else it does not find the right path?
EDIT:
The command I execute is:
build/bin/mytool source.cpp -- -I(list of headers without system headers)

compiler error - opencv2/highgui.hpp: No such file or directory

I am a "very" beginner of OpenCV. I just downloaded it for my Windows and extracted.
I have read this post: http://opencv-srf.blogspot.ro/2011/09/capturing-images-videos.html about how to read webcam and I copied and pasted the code in a C++ file I created in "include" folder of OpenCV extracted archive.
When I try to run the program I get this error: Error in: /opencv/build/include/opencv2/highgui/highgui.hpp - opencv2/highgui.hpp: No such file or directory.
What should I do?
Thank you all!
EDIT
I opened: "/opencv/build/include/opencv2/highgui/highgui.hpp" and I can see that it includes this path "opencv2/highgui.hpp". If I change it to "../highgui.hpp" it works but I get other errors like this for other files... What should I do?
The problem is that you are not supposed to create your "cpp" file in the OpenCV "include" directory. You need to create it in a separate directory and then add OpenCV "include" as additional include directory for the compilation step.
The way to achieve this depends on your C++ development environment. If you are using Visual Studio, then you need to open project property pages, go to "C/C++ -> General" and add the path to OpenCV "include" directory to "Additional Include Directories". In case of some other compiler/IDE, you can find out how to do this by reading the corresponding documentation.

Cannot open include file: 'occi.h': No such file or directory

I am trying to compile an existing C++ project but get this error:
fatal error C1083: Cannot open include file: 'occi.h': No such file or directory
What I did is I went to this link:
http://www.oracle.com/technetwork/topics/winsoft-085727.html
and downloaded the first (basic) package.
Then unzipped the folder and modified PATH variable like this:
C:\Program Files\Atmel\sam-ba_2.12\drv\;C:\Program Files\Atmel\sam-ba_2.12;C:\Program Files\ATMEL Corporation\AT91-ISP v1.4\Library;C:\MSYS\1.0\bin;C:\MSYS\1.0\local\bin;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin;D:\instantclient_12_1
last being path to oracle.
But I still get the error, can someone help?
PS I noticed in my project there are lines like:
#include "occi.h"
Maybe it is because of this?
The basic package isn't enough. Its description says "All files required to run OCI, OCCI, and JDBC-OCI application" (emphasis added); with just that you can run an OCI program, but you can't compile one. You need to download other instant client components. Specifically for the occi.h header you need the fifth file listed:
*Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
If you download and unzip that in the same place you unzipped the basic package, your instant client directory will gain an sdk folder, which includes all the OCI header files.
You'll then need to compile with -I D:\instantclient_12_1\sdk\include so your compiler knows where to look for the occi.h and other header files. You may also need -L to tell it where to find the Oracle libraries; presumably you already have -lclntsh and/or -locci, which refer to libraries you should have already from the basic package.