I have a .cpp file which can be compiled by sourceRcpp() successfully. Now I use Rcpp.package.skeleton() for it, and it generates the related directory. Then I run the code R CMD Install on the command line, but it showed a warning with an ERROR:
compilation failed for package...
I'm Windows user and use RStudio. I've followed some advice and found the file Makevars.win, it has only one line
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
Maybe I need to add Rcpp:::LdFlags() or something. I've already install Rtools before because I can compile and install my own packages without using Rcpp.
Could you give me some advice how to deal with it?
If you are in RStudio already do this:
File -> New Project -> New Directory -> R Package
Important: Switch the toggle in 'Create Package' from 'R Package' to 'R Package w/Rcpp'.
Build the package. It will work, just like Rcpp.package.skeleton().
Copy your source file into src/.
Build the package again. This will automagically run compileAttributes() for you which is what you failed to do manually.
All this is documented.
Related
I'm installing dependencies for some project which downloads dependencies with vcpkg (the project is Hyperledger Iroha, but it does not matter). Unfortunately when compiling dependencies with my compiler (g++ 12.1.0) one of packages (abseil) is not compiling.
The reason why it is not compiling is easy to fix in code - just one line to change.
The line is pointed by cmake:
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:146 (message):
Command failed: /usr/bin/cmake --build . --config Debug --target install -- -v -j13
Working Directory: /home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/buildtrees/abseil/x64-linux-dbg
See logs for more information:
/home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/buildtrees/abseil/install-x64-linux-dbg-out.log
and the error is:
/home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/buildtrees/abseil/src/ca9688e9f6-e4cda1d679.clean/absl/debugging/failure_signal_handler.cc:139:32: error: no matching function for call to ‘max(long int, int)’
139 | size_t stack_size = (std::max(SIGSTKSZ, 65536) + page_mask) & ~page_mask;
| ~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12.1.0/algorithm:60,
The reason is easy to fix - I just need to change one line to fix this.
Unfortunately when I'm changing the line of code and then after rerunning:
vcpkg install abseil
my changes are being removed before compilation. I found option which should help:
--editable, but it is happening again.
I would like to ask what is more professional (but still fast) way to change files, which are being build with vcpkg and containing errors?
The one solution which I found is that I can edit package:
-- Using cached /home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/downloads/abseil-abseil-cpp-997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz
when I edit the package I see error:
File path: [ /home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/downloads/abseil-abseil-cpp-997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz ]
Expected hash: [ bdd80a2278eef121e8837791fdebca06e87bfff4adc438c123e0ce11efc42a8bd461edcbbe18c0eee05be2cd6100f9acf8eab3db58ac73322b5852e6ffe7c85b ]
Actual hash: [ cf8bb1676d2fcba8bdd4bc30e2060bc5552a348d6e192561aec2763460120b10dcb86e29efe60d972d4b241783563bc8067381c48209daee4ecc429786ef6bba ]
so I can edit file containing the hash: ports/abseil/portfile.cmake
Another solution is to run proper cmake of the abseil project with VERBOSE=1, then copy failing build commands after that edit files and rerun commands.
I know that my solutions are quite dirty so I would like to know if there is cleaner way to solve problem - how to edit source code of a library when it is not compiling when we use vcpkg package manager?
This is how I do it:
Run install with --editable
vcpkg install abseil --editable
Initialize git repo in source dir:
cd buildtrees/abseil/src/_random_string_/
git init .
git add .
git commit -m "init"
Patch the library
Verify the library builds by calling install with --editable again
vcpkg install abseil --editable
Create patch from changes (or commits)
git diff > fix_build.patch
Copy patch into port dir and adjust portfile.cmake
vcpkg_from_github(
REPO google/abseil
...
PATCHES fix_build.patch # <-- this is our patch
)
Copy the port directory into your project's overlay-ports dir. -OR- Update port version, submit it into your custom registry.
(optional, but appreciated) Create PR in upstream and vcpkg main repo.
This might be stupidiest and newbie's question, but how do I actually compile D project with DMD on windows?
I tried these commands:
dmd *
dmd *.d
cd .. && dmd {DirectoryName}
dmd file1.d file2.d
But neither of them compile the project to executable.
I want to produce .exe file out of that project, but it seems I can't. I can only compile one file in the project or compile multiple, but only .obj file, not .exe...
DUB is the easiest for beginners:
C:\Users\217216x715132\Desktop\tmp1>dub init
Package recipe format (sdl/json) [json]:
Name [tmp1]:
Description [A minimal D application.]:
Author name [217216X715132]:
License [proprietary]:
Copyright string [Copyright © 2019, 217216X715132]:
Add dependency (leave empty to skip) []:
Successfully created an empty project in 'C:\Users\217216x715132\Desktop\tmp1'.
Package successfully created in .
C:\Users\217216x715132\Desktop\tmp1>dub run
Performing "debug" build using dmd for x86.
tmp1 ~master: building configuration "application"...
Linking...
Running .\tmp1.exe
Edit source/app.d to start your project.
C:\Users\217216x715132\Desktop\tmp1>
You can copy all your d files to your-project\source\ directory and let dub do all the hard work.
dub init doesn't work from git bash for some reason, as it waits for input on CLI. So you need to dub init from cmd.exe. dub run should work fine from git bash.
If you run it from git bash, press enter key 7 times, all the defaults will be accepted and the project will be created.
arun MINGW64 ~/Desktop/tmp1$ dub init
Package recipe format (sdl/json) [json]: Name [tmp1]: Description [A minimal D application.]: Author name [217216X715132]: License [proprietary]: Copyright string [Copyright © 2019, 217216X715132]: Add dependency (leave empty to skip) []: Successfully created an empty project in 'C:\Users\217216x715132\Desktop\tmp1'.
Package successfully created in .
arun MINGW64 ~/Desktop/tmp1$
Related issue in DUB
If you don't like Dub, you might try rdmd, which comes with the standard D compiler. E.g suppose you have a main.d file that imports other files:
rdmd --build-only main.d # Build
rdmd --build-only -g -debug main.d # Build in debug mode
rdmd main.d # Build temporary executable and run it
If you want to see the raw commands that dub executes to build your project, you can use:
dub build --force --verbose
I have an R package built in Rstudio, which contains a lot of c++ files. After successfully building the R package, I try to install it using the command R CMD INSTALL --library=**my path** myfile.tar.gz in the terminal.
Since I have a lot of c++ code in my R package, g++ tries to compile this code but could not find certain header files.
Is there a way to point the g++ compiler to the location of my header files, I tried using PKG_CXXFLAGS but in vain.
The question comes from my puzzlement when compiling a makefile for Deep Learning framework Caffe on Ubuntu, but it relates, I believe, to a more general phenomenon of the nature of compiling a C++ makefile.
After "make all", the resulting files from the compilation were put in a hidden folder: .build_release, not in the respective folders where the cpp files are.
Then when I tried to run the following lines:
./data/mnist/get_mnist.sh
./examples/mnist/create_mnist.sh
I was getting an error that the system does not find the file:
./create_mnist.sh: 16: ./create_mnist.sh: build/examples/mnist/convert_mnist_data.bin: not found
But the file actually existed in the .build_release folder.
What happened and how to fix this problem?
The issue is not with make, you simply need to follow the instructions carefully. The BUILD_DIR is specified by Makefile.config. By default this folder is named build. Once you followed the compilation instructions:
cp Makefile.config.example Makefile.config
# Adjust Makefile.config (for example, if using Anaconda Python)
make all
make test
make runtest
Navigate to build:
cd build
./data/mnist/get_mnist.sh
./examples/mnist/create_mnist.sh
I have erlang installed on a normal instance unix instance on AWS.
Now I am trying to install ejabberd, however I am stuck at this particular step.
The installation steps I use are:
sudo ./configure --with-erlang=/home/ec2-user/otp_src_17.4
sudo make
sudo make install
However when I get to "sudo make", I get the following error:
/home/ec2-user/otp_src_17.4/bin/escript rebar compile && :> deps/.built
==> p1_utils (compile)
==> p1_cache_tab (compile)
==> p1_tls (compile)
Compiling /home/ec2-user/ejabberd-14.12/deps/p1_tls/c_src/p1_tls_drv.c
/home/ec2-user/ejabberd-14.12/deps/p1_tls/c_src/p1_tls_drv.c:23:24: fatal error: erl_driver.h: No such file or directory
#include <erl_driver.h>
^
compilation terminated.
ERROR: compile failed while processing /home/ec2-user/ejabberd-14.12/deps/p1_tls: rebar_abort
make: *** [deps/.built] Error 1
Not sure why this error is occurring. Erlang was definitely installed because I could check its version from the console.
I suspect there might be some configuration issues?
Judging from the ejabberd source code, the --with-erlang option handling does nothing to ensure that the C header files needed to correctly compile Erlang drivers and NIFs are included from the specified directory. I think this is an ejabberd build system bug.
You need to tell the configuration and make steps where to find Erlang to ensure that the C compiler searches your Erlang installation for header files. Normally you can do this by specifying CFLAGS explicitly as part of the configure step, but that won't work in this case because that variable doesn't make its way through to the rebar build. A different way to do this that should work in this case is to make sure your Erlang installation is found in the PATH:
export PATH=/home/ec2-user/otp_src_17.4/bin:$PATH
./configure --with-erlang=/home/ec2-user/otp_src_17.4
make
sudo make install
The ejabberd build system looks for erl and erlc in the PATH and then uses the root directory of where it finds them to look for includes files and libraries also needed for the build.
Also, note that you probably do not need to use sudo for either the configure or make steps, but rather only for the make install step.