0

I have tried to understand: (Manipulating the search path for include files), but I am having troubles. Note that I am new.

I have tried putting the following in the #include with brackets: #include "boost/1.73.0/include/boost/math/tools/promotion.hpp" where "= bracket.

I have tried to add the search path to the options file in make. I used: -I/boost/1.73.0/include/boost/math/tools and #include "promotion.hpp"

The person that created the original OpenFoam solver had nothing in the options file, and had #include "boost/math/tools/promotion.hpp" where "= bracket.

I am not compiling one file, I am using Allwmake to compile an OpenFoam solver. In some cases, the file path has changed since the solver was written for an older version. So, I am updating.

A Computational Fluid Dynamics site suggested I install boost under home directory. The boost path is not recognized.

I ask for "complete" explanation because I have tried a lot. I am lost.

Each gave me the compilation errors that the file or directory does not exist.

I need help. I have read a lot, I am ignorant still, and I need a complete explanation.

Thanks!

Chris Harding
  • 27
  • 1
  • 8
  • have you tried cd /boost/1.73.0/include/boost/math/tools ? – Felipe Jun 01 '20 at 19:33
  • It's really not very complicated, you just add the path specifed by (one of the) `-I` options to the path specified by `#include` and that file must exist, e.g. if you have `-I/xxx/yyy` and you have `#include "aaa/bbb.h"` then there must be a file called `/xxx/yyy/aaa/bbb.h`, simple really. – john Jun 01 '20 at 19:36
  • @John: The boost directory is part of the HOME. I know the file and path exists, but the compiler tells me they don't exist. I have tried what you say, but I am missing something. – Chris Harding Jun 01 '20 at 19:45
  • @ChrisHarding So currently what does your -I option say, and what does your #include say? – john Jun 01 '20 at 19:46
  • @John, I posted in my comment what the -I option was in Make options file. – Chris Harding Jun 01 '20 at 20:13
  • @ChrisHarding Are you really trying to include a file called "abcd.hpp"? Because there is no such file. It would explain a lot. On the other hand if that isn't the name of the file you are trying to include could you update this post with the real file name. – john Jun 01 '20 at 20:29
  • @John: Thanks. As I mentioned, I am new so I lack some of the vocabulary. I am sure you would have to learn OpenFoam vocabulary if we were talking about OpenFoam. So, please be patient. In my xxx.h file, the include is: #include "boost/math/tools/promotion.hpp" where "=bracket. In my Make options file, I added: -I/boost/1.73.0/include – Chris Harding Jun 01 '20 at 20:40
  • So since boost is installed in your home directory (I think you said that somewhere) then `-I/boost/1.73.0/include` is wrong, it should be `-I~/boost/1.73.0/include` – john Jun 01 '20 at 20:46
  • @John: I tried the tilda, again, and I get an error: "fastExactClosure.H:3:10: fatal error: boost/math/tools/promotion.hpp: No such file or directory" – Chris Harding Jun 01 '20 at 20:57
  • So try the following command `ls ~/boost/1.73.0/include/boost/math/tools/promotion.hpp` and tell me what you see. – john Jun 01 '20 at 21:00
  • @ChrisHarding Well I hope you got it sorted out. Undoubtedly the problem is that you are telling your compiler to include a file that doesn't exist. How you are telling it that, and what you should be telling it instead unfortuntealy we never established. – john Jun 02 '20 at 04:42
  • @Johh: Sorry. The output, for the ls path is: /home/happys5/boost/1.73.0/include/boost/math/tools/promotion.hpp I am still having problems. I changed the path to the latter, and got another error that such file or directory does not exist. I have to go to sleep. – Chris Harding Jun 02 '20 at 05:25
  • @John: I changed the path of my xxx.h file to: #include "boost/math/tools/promote.hpp" where "= bracket. I changed Make options file to: -I ($HOME)/happys5/boost/1.73.0/include Now I get a different error, thanks for helping me out. As I said, I am learning. – Chris Harding Jun 02 '20 at 05:38
  • @ChrisHarding Sleep is good. `-I ($HOME)/happys5/boost/1.73.0/include` is wrong in two different ways. Firstly it should be `$(HOME)` not `($HOME)`, secondly your home directory is `/home/happys5` so saying `$(HOME)/happys5/boost/1.73.0/include` includes happys5 on the path twice. – john Jun 02 '20 at 07:29
  • @ChrisHarding Maybe just a typo here but `#include "boost/math/tools/promote.hpp"` is wrong it should be promotion not promote. – john Jun 02 '20 at 07:30
  • @ChrisHarding This seems correct to me `-I~/boost/1.73.0/include` (or same thing `-I$(HOME)/boost/1.73.0/include`) and `#include `. However you have already tried that combination I think, and the `ls` command I asked you to do proves that file exists. So I'm a little confused. – john Jun 02 '20 at 07:35
  • @ChrisHarding So two things I can think of. Firstly you keep saying `where "= bracket`, can you explain what you mean by that? Secondly maybe you are adding the `-I` option to your make file incorrectly in some way. That takes us into a whole different set of issues. Is it possible with the build system you are using for you to quote the compiler command that is being executed by your make file. Something like `g++ -c -I some_path some_filename` – john Jun 02 '20 at 07:36

1 Answers1

0

You need to add the directory to the compiler's include search path. For g++ and clang it's done via -I option. In your case that would be

g++ -I/boost/1.73.0/include.

Never fixup your include directories in the source code. This would tie the source code to your specific configuration. It would simply make the code non-compilable on any other machine.

jvd
  • 764
  • 4
  • 14
  • When I try what you have suggested, I get "g++: fatal error: no input files" – Chris Harding Jun 01 '20 at 19:39
  • 1
    @ChrisHarding Obviously you have to compile something as well. There's no point in running g++ without specifying a file to compile or link. – john Jun 01 '20 at 19:40
  • 1
    Of course, you need to add your input files, optimization options, output files, etc. It would generally look like this: g++ -Iinclude_dirs input_file0 input_file1 ... input_fileN -o compiled_file -O – jvd Jun 01 '20 at 19:41
  • I forgot to add the period. When I do what you said, completely, I get the following error. "/usr/bin/ld: cannot find .: File not recognized" – Chris Harding Jun 01 '20 at 19:50
  • 1
    Could you, please, just post the concrete command line that you are using? – jvd Jun 01 '20 at 19:51
  • @jvd: I tried your exact line: "gcc+ -I/boost/1.73.0/include ." I received an error that I reported. – Chris Harding Jun 01 '20 at 19:59
  • Instead of ".", it should be a name of a C++ file. For example, g++ -I/boost/1.73.0/include test.cpp This command line would compile the code and since since there is no -o option, it would output a.out executable. – jvd Jun 01 '20 at 20:01
  • @jvd Is there a version of gcc called gcc+? – john Jun 01 '20 at 20:02
  • @john, well caught. Fixed the comment. I added the param to the OPs command line. – jvd Jun 01 '20 at 20:04
  • @jvd: I am compiling an OpenFoam Solver that was created by another person. So, I use ./Allwmake. – Chris Harding Jun 01 '20 at 20:09