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++.
Related
I'm trying to build qt project but I keep getting error about no existing header in moc object moc_SerialPortManager.cpp. I moved with bash to that directory and used cd cmd with the path written in mock object and it leads to the correct directory. Does anybody have a slightest idea how to resolve it? At this point it's quite big project so just please tell me what could I publish to make this easier for you?
I have it all on git https://github.com/Orpiczy/AcornScanner/compare/fronAndBackJoin if you wish to check it out
I'm using Mingw compiler 8.1.0 64-bit for c++ and Qt 6.2.0, I'm working on windows10
moc_SerialPortManager.cpp
#include <memory>
#include "../../../../../../source/controllers/LowLevelFunctionality/DeviceController/ProfilometerManager/SerialPortManager.hpp"
#include <QtCore/qbytearray.h> ...
logs
E:\Dokumenty\AiR_rok_4\S7\EngineeringThesis\AcornScanner\cm\cm-lib\build\windows\gcc\x64\debug.moc\moc_SerialPortManager.cpp:10: error: ../../../../../../source/controllers/LowLevelFunctionality/DeviceController/ProfilometerManager/SerialPortManager.hpp: No such file or directory
........\AcornScanner\cm\cm-lib\build\windows\gcc\x64\debug.moc\moc_SerialPortManager.cpp:10:10: fatal error: ../../../../../../source/controllers/LowLevelFunctionality/DeviceController/ProfilometerManager/SerialPortManager.hpp: No such file or directory
#include "../../../../../../source/controllers/LowLevelFunctionality/DeviceController/ProfilometerManager/SerialPortManager.hpp"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that the layout of your repository differs from your local filesystem:
.../debug/.moc/
vs.
.../debug.moc/
Therefore the relative path steps up one level too much and results in a non-existing path.
It is generally considered bad practice to put automatically generated files (i.e. moc files) under version control. I would assume if you remove the whole build directory and build again you will be fine.
I'm trying to use tensorflow as a external library in my C++ application (mainly following this tutorial). What I done so far:
I have cloned the tensorflow reporitory (let's say, that the repo root dir is $TENSORFLOW)
Run /.configure (which all settings default, so no CUDA, no OpenCL etc.).
Build shared library with bazel build -c /opt //tensorflow:libtensorflow_cc.so (build completed successfully)
Now I'm trying to #include "tensorflow/core/public/session.h". But after including it (and adding $TENSORFLOW and $TENSORFLOW/bazel-genfiles to include path), I'm receiving error:
$TENSORFLOW/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:42:
fatal error: unsupported/Eigen/CXX11/Tensor: No such file or directory
There is a github issue created for similar problem, but it's marked as closed without any solution provided. Also I tried with master branch as well as v.1.4.0 release.
Do you happen to know, what could cause this kind of problem and how to deal with it?
I (and many others) agonized over the same problem. It probably can be solved using bazel but I don't know that tool well enough and now I solve this using make. The source of confusion is that a file named Tensor is included and it itself includes a file named Tensor, which has caused some people to wrongly conclude Tensor is including itself.
If you built and installed the python .whl file there will be a tensorflow directory in dist-packages and an include directory below that, e.g. on my system:
/usr/local/lib/python2.7/dist-packages/tensorflow/include
From the include directory
find . -type f -name 'Tensor' -print
./third_party/eigen3/unsupported/Eigen/CXX11/Tensor
./external/eigen_archive/unsupported/Eigen/CXX11/Tensor
The first one has
#include "unsupported/Eigen/CXX11/Tensor"
and the file that should satisfy this is the second one.
So to compile session.cc that includes session.h, the following will work
INC_TENS1=/usr/local/lib/python2.7/dist-packages/tensorflow/include/
INC_TENS2=${INC_TENS1}external/eigen_archive/
gcc -c -std=c++11 -I $INC_TENS1 -I $INC_TENS2 session.cc
I've seen claims that you must build apps from the tensorflow tree and you must use bazel. However, I believe all the header files you need are in dist-packages/tensorflow/include and at least for starters you can construct makefile or cmake projects.
Slightly off-topic, but I had the same error with a C++ project using opencv-4.5.5 and compiled with Visual Studio (no problem with opencv-4.3.0, and no problem with MinGW).
To make it work, I had to add to my root CMakeLists.txt:
add_definitions(-DOPENCV_DISABLE_EIGEN_TENSOR_SUPPORT)
If that can help someone...
the problem was actually in the relative path of the header file taken in the Tensor file.
installed path for Tensor is /usr/include/eigen3/unsupported/Eigen/CXX11/Tensor
but mentioned in the Tensor file is "unsupported/Eigen/CXX11/Tensor"
So there should be an entry upto /usr/include/eigen3/ in the project path to run this correctly so that it can be used.
I am trying to run Allegro on my mac but I keep getting
main.cpp:1:10: fatal error:'allegro5/allegro.h' file not found
error.
I have installed allegro successfully and I can find the header files in /usr/local/include/allegro5 . I added a path to my environment variable and when I do echo $PATH I can see /usr/local/include. In the sample program I am trying to run the include is like this -
#include <allegro5/allegro.h>
and I run-
make main
I can see the header files I have included, why isn't mac able to find the files present in that path?
As #PaulR mentioned, PATH is where the shell looks for commands, not for where the compiler looks for includes. You could also add the -I/usr/local/include option to your command line as a way to resolve it.
You could check C_INCLUDE_PATH or CPLUS_INCLUDE_PATH or INCLUDE_PATH (not sure which it's looking for).
I'm trying to get up and running with Boost, so I'm trying to compile the simple example problem from Boost's "Getting Started" page. I've had two issues, and I'm not sure they're related (I'm better than a novice, but not by much) but maybe they're related...
1st issue: the "tar --bzip2 -xf /path/to/boost_1_49_0.tar.bz2" command didn't work (yes, I put the correct path in, but it gave me some errors, I forget what they were) so I used "tar -xjvf " from the directory where boost_1_49_0.tar.bz2 was located. That de-compressed the zip file and I proceeded with the example...
2nd issue: The example.cpp file will not compile, the first statement in the code is #include "boost/lambda/lambda.hpp" but then for every header file lambda.hpp is trying access, there's a "No such file or directory" compile error. For example, here are two (of the six, and I get errors for all 6) header files within lambda.hpp and the errors displayed by the cygwin compiler:
boost/lambda/lambda.hpp:14:33: boost/lambda/core.hpp: No such file or directory
boost/lambda/lambda.hpp:21:52: boost/lambda/detail/operator_actions.hpp: No such file or directory
If it helps, this is the command I'm running to compile (I generally create the executable in a separate -o command):
g++ -c example.cpp
Why can't the system find these? I added the installed directory (path/to/boost_1_49_0) to the PATH variable before I started so I know that's no it. Thanks for any advice...
(I've looked on stackoverflow and there were similar issues, but no solutions that worked)
It looks like you've already solved the first issue: namely, that you must specify the -j flag on tar to untar a bzip2'd file.
For the second issue, you need to specify boost on your include path, either by specifying it with the -I command line option or via the CPLUS_INCLUDE_PATH environment variable.
I installed dmd (2.0 ?) using the windows installer and am trying to compile the following program:
module tcpechoserver;
import std.stdio;
const int MAXPENDING = 5;
int main(char[][] argv)
{
if(argv.length != 2){
writef("Usage: %s <port>", argv[0]);
}
return 0;
}
But I get the following compiler error:
Error: module stdio cannot read file 'std\stdio.d'
Are there some paths I have to specify in order to get the standard library to work?
When you get errors like that, it means that DMD cannot find the import file. If you import foo.bar.xyz, then it expects it to find a xyz.d in some directory foo\bar\.
It searches for this directory in all its standard import paths, as well as the current directory (for example, if you added a directory std next to your tcpechoserver.d with a stdio.d in it, then it would use that). Of course, you don't want that -- you want the standard stdio.d.
You can find what directories it looks it by opening the file
C:\D\dmd2\windows\bin\sc.ini (assuming you installed to the default directory).
Inside that, it should contain the line:
DFLAGS="-I%#P%\..\..\src\phobos" "-I%#P%\..\..\src\druntime\import"
which is telling the compiler to search those paths when looking for import directories. If you don't have that line for whatever reason (or if the line is different) then try adding this line into sc.ini (anywhere under the [Environment] header should do.
Also ensure that the dmd2 directory contains a \src\phobos\std\stdio.d file.
If both these don't work, then I'd recommend reinstalling from scratch.
Look at the ~\windows\bin\sc.ini file in your dmd installation directory. It contains implicit command line arguments for dmd, which should look as this for dmd 2.048:
LIB="%#P%\..\lib";\dm\lib
and
DFLAGS="-I%#P%\..\..\src\phobos" "-I%#P%\..\..\src\druntime\import"
If they are ok, and it doesn't works, your installation is probably broken. I recommend you to simply download zipped version of compiler and unpack it over your installation.