I want to build a cuda plugin for an other project written in C++ using MPI.
I got the following situation:
startingpoint.cpp is a c++ file including the cudaintegrator.h and
includes datastructure.h
cudaintegrator.h is the header file for a
cuda file including datastructure.h
cudaintegrator.cpp is the
implemenation of cudaintegrator.h
datastructure.h is a header file
specifing some datastructures
the files are organized like that:
/trunk/
/src
/folder1
/folder2
/startingpoint.cpp
/folder3
/cudaintegrator.h
/cudaintegrator.cpp
/folder4
/folder5
/datastructure.h
When I run nvcc from my trunk dir with the following command:
/usr/local/cuda/bin/nvcc -c -o src/folder1/folder3/cudaintegrator.o src/folder1/folder3/cudaintegrator.cu
the included file `#include "folder4/folder5/datastructure.h" is not found:
src/folder1/folder2/cudaintegrator.h:12:33: fatal error: folder4/folder5/datastructure.h: No such file or directory
When I run mpic++ for the compilation of startingpoint.cpp, which uses the same include, the datastructure.h is found.
I suspect that the working directory of nvcc and mpic++ are somehow different(?) even both are run from the trunk directory.
When I change the include to ../../folder4/folder5/datastructure.h the file itself is found, but subsequent includes fail for the same reason. I can not change the includes in all subsequent files because they can't be found by mpic++ in this case.
Does anyone have a suggestion how I should include the files in this situation correctly, or how to instruct nvcc to find the included files?
Providing include paths (-I) to the nvcc invocation should be enough (if not, it uses relative include paths only, that's why adding ../.. works for a single include).
Related
I have downloaded the source code to do some benchmark for couple of C++ library. I don't have much knowledge in C++. I downloaded the libraries. When I try to compile the code
g++ test_matrix_pseudoinverse.cpp -o test_matrix_pseudoinverse
I get this error
test_matrix_pseudoinverse.cpp:26:64: fatal error:
opencv2.4/modules/core/include/opencv2/core/core.hpp: No such file or
directory #include
^ compilation terminated.
The source code with all the libraries are in github
https://github.com/shiblybcc/linear-algebra-benchmark
I have downloaded the code from here. It would be nice if someone could tell me why I am getting this error and how to run the code without any error.
I am on linux and I have added opencv2 folder in /usr/local/include directory.
I guess this is resulted from not setting the include path if the file complained by the compiler does exist. Suppose your OpenCV source code tree is under /home/yourhome (i.e the full path to the file reported not existed should be /home/yourhome/opencv2.4/modules/core/include/opencv2/core/core.hpp), you need to specify the include path by -I/home/yourhome argument. Therefore the full command line to build should be as:
g++ -I/home/yourhome test_matrix_pseudoinverse.cpp -o test_matrix_pseudoinverse
I am trying to install the hep-mc library listed here: https://github.com/cschwan/hep-mc for use on compute using the instructions listed in the documentation here: https://github.com/cschwan/hep-mc#installation . To compile one of the example files, I typed this into the terminal:
g++ -L/usr/local/hep-mc/include vegas_mpi_ex.cpp -o vegas_mpi
but I get these error messages:
mpi_vegas_ex.cpp:1:22: error: hep/mc.hpp: No such file or directory
mpi_vegas_ex.cpp:2:26: error: hep/mc-mpi.hpp: No such file or directory
mpi_vegas_ex.cpp:8:17: error: mpi.h: No such file or directory
in the beginning of my code, the declarations are like this:
#include "hep/mc.hpp"
#include "hep/mc-mpi.hpp"
#include <mpi.h>
The tutorial states that I should point the compiler to the location of the "include" folder that contains all the .hpp files, which I have done. Do you guys have any idea as to what I'm doing wrong?
It should also be noted that the compiler cannot find the mpi.h directory even though I have loaded the openmpi module.
-L sets paths where the linker searches for libraries to link. The option you're looking for is -I, which sets the paths where the compiler searches for #included files.
g++ -L/usr/local/hep-mc/include vegas_mpi_ex.cpp -o vegas_mpi
Oops!
g++ -I/usr/local/hep-mc/include vegas_mpi_ex.cpp -o vegas_mpi
-L specifies the path to library files; -I specifies the path to includes.
This is confusing because in terms of project management and distribution, we consider "the library" to include both binaries and header files, as well as documentation and all sorts of goodies. But at a technical level that is not what "library" means.
I installed OpenBlas and could compile C programs linked to OpenBlas by using
gcc testOpenBlas.c -I /opt/OpenBLAS/include/ -L/opt/OpenBLAS/lib -lopenblas
If I try to link c++ programs using g++ and the same linker options I get the error:
testOpenBlas.cpp:1:28: fatal error: OpenBlas/cblas.h: No such file or directory
#include <OpenBlas/cblas.h>
Any hints?
Here is what I did:
I had to recompile OpenBlas again with g++.
I found that the common.h file exists in the source folder, so I had to include it instead of the installation folder '/opt/OpenBlas'. I still use '-L/opt/OpenBLAS/lib' flag.
Then the problem was solved.
This include directive is looking for the path OpenBlas/cblas.h in all your include directories, in particular also in /opt/OpenBLAS/include/.
So the question is: does there exist a file /opt/OpenBLAS/include/OpenBlas/cblas.h?
Also I think you might have to specify the -I flag before the source file.
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.
Hi i would like to include a external library call NTL. its in the path as followed:
#include "WinNTL-5_4_2/include/NTL/tools.h"
My file is key.cpp and its reside in the same folder as NTL . but when i compile, it came up with another error which is ..
In file included from keygen.cpp:6:0:
WinNTL-5_4_2/include/NTL/tools.h:5:24: fatal error: NTL/ctools.h: No such file or directory
compilation terminated.
As its need another file call ctools.h, how do i includes tools.h to make ctools.h work also
I tried type
me#ubuntu:~/GG$ g++ keygen.cpp -o keygen -l WinNTL-5_4_2/include/
keygen.cpp:6:23: fatal error: NTL/tools.h: No such file or directory
but it doesnt work still.
Based on the error message, you should try changing your include to:
#include "NTL/tools.h"
and make sure that WinNTL-5_4_2/include is in your compiler's search path for include files.
You need to add the root directory as part of your project's search path for include files. It depends on your environment exactly how to do this, but there are usually two search paths -- one for include files and another for compiled libraries. Set that with the directory that contains the WinNTL-5_4_2 directory and you should be golden.
You had to add "fullpath/WinNTL-5_4_2/include" in you include path of your compiler (either by -I for gcc or in the include path list of a visual studio project)
Expecting that ctools.h exists in ".../WinNTL-5_4_2/include/NTL"