I am developing part of my R package in C++ using Rcpp and I need to use a Linear Programming Solver.
After comparing some benchmarks using the solvers implementation into R (lpSolveAPI, Rglpk, Rsymphony and so on) I have decided to use GLPK. However, I have found no good way to use it in my C++ code developing under Windows.
Simply put, there is no simple way to just install GLPK and call it using something like
#include <glpk.h>
and I have found no implementations in R packages so that I can use a shortcut using Rcpp attributes like
// [[Rcpp::depends(package)]]
Any ideas?
I'm sure you are aware of the Rglpk package and its predecessor glpk. Often in these cases, it's helpful to stand on the shoulders of those that came before us. Having said that, we gleam from the package sources the following:
The source of Rglpk requires a pre-existing system install, does not enable linking, and is specific to Linux.
The source of glpk installs the library headers directly in R and it seems to also provide direct wrappers into the library.
Given the current implementations and your requirements, you would basically have to create an RcppGLPK package. This is primarily because no one really has a solution for what you need. I would highly suggest that you look at how RcppGSL is structured.
Related
I know there are ways of using Tensorflow in C++ they even have a documentation for it but I can seem to be able to get the library for it. I've checked the build from source instructions but it seems to builds a pip package rather than a library I can link to my project. I also found a tutorial but when I tried it out I ran out of memory and my computer crashed. My question is, how can I actually get the C++ library to work on my project? I do have these requirements, I have to work on windows with Visual Studio in C++. What I would love to is if I could get a pre-compiled DLL that I could just link but I haven't found such a thing and I'm open to other alternatives.
I can't comment so I am writing this as an answer.
If you don't mind using Keras, you could use the package frugally deep. I haven't seen a library myself either, but I came across frugally deep and it seemed easy to implement. I am currently trying to use it, so I cannot guarantee it will work.
You could check out neural2D from here:
https://github.com/davidrmiller/neural2d
It is a neural network implementation without any dependent libraries (all written from scratch).
I would say that the best option is to use cppflow, an easy wrapper that I created to use Tensorflow from C++ easily.
You won't need to install anything, just download the TF C API, and place it somewhere in your computer. You can take a look to the docs to see how to do it, and how to use the library.
The answer seems to be that it is hard :-(
Try this to start. You can follow the latest instructions for building from source on Windows up to the point of building the pip package. But don't do that - do this/these instead:
bazel -config=opt //tensorflow:tensorflow.dll
bazel -config=opt //tensorflow:tensorflow.lib
bazel -config=opt tensorflow:install_headers
That much seems to work fine. The problems really start when you try to use Any of the header files - you will probably get compilation errors, at least with TF version >= 2.0. I have tried:
Build the label_image example (instructions in the readme.md file)
It builds and runs fine on Windows, meaning all the headers and source are there somewhere
Try incorporating that source into Windows console executable: runs into compiler errors due to conflicts with std::min & std::max, probably due to Windows SDK.
Include c_api.h in a Windows console application: won't compile.
Include TF-Lite header files: won't compile.
There is little point investing the lengthy compile time in the first two bazel commands if you can't get the headers to compile :-(
You may have time to invest in resolving these errors; I don't. At this stage Tensorflow lacks sufficient support for Windows C++ to rely on it, particularly in a commercial setting. I suggest exploring these options instead:
If TF-Lite is an option, watch this
Windows ML/Direct ML (requires conversion of TF models to ONNX format)
CPPFlow
Frugally Deep
Keras2CPP
UPDATE: having explored the list above, I eventually found the following worked best in my context (real-time continuous item recognition):
convert models to ONNX format (use tf2onnx or keras2onnx
use Microsoft's ONNX runtime
Even though Microsoft recommends using DirectML where milliseconds matter, the performance of ONNX runtime using DirectML as an execution provider means we can run a 224x224 RGB image through our Intel GPU in around 20ms, which is quick enough for us. But it was still hard finding our way to this answer
I'm new to C++ but I'm having a hard time working out how to use libcurl with a c++ program.
A) Should I install libcurl with apt-get for the server or install it as some sort of library in C?
B) What is the point of using a c++ binding for libcurl, can I not use it directly without a binding? https://github.com/JosephP91/curlcpp
Sorry if this is obvious.
You need a library to link to. Not quite sure whether apt-get provides that, but checking the project website will probably turn up a download link. Alternatively, you can build the lib from source.
As for the C++ wrapper, you are correct in that you don't need it. It was probably written for the sake of keeping things object-oriented and perhaps to add some convenience. Otherwise you can use it the old C way without any problems.
For commodity sake, always is easier to install with the apt-get/yum or the install system you use in your OS.
A) In my company we have it compiled on one folder. In my house I usually install it from official repositories, I find it easier but it depends if you want to distribute your product and keep your code fixed with one version.
B) That's always up to you, I usually use it directly, I prepare my own eventing system(kqueue/epoll or using libuv/libev/libevent/asio), and assign the callbacks.
A) you have to have the lib installed in your SO's. Otherwise you cannot link it in the program.
B) part1: The point of c++ binding for libcurl, it's for allow you do:
#include "curl_easy.h"
Otherwise you would not be allowed to do it, without implement by yourself the curl_easy.h, remember that it has only C api interface (taken by homepage of libcurl), it allows you to use it because its C but not in native mode.
B) part2: yes you can, but you will need to use the C version of the libcurl. Not the C++ version like you do by the biding.
I'm a student. I have made a small language for computer-architectural simulations as a part of my project. I have made a parser+translator for this language using Antlr3. Stuff written in my language gets translated to C++ code, which can be compiled and executed by the user to run the simulation.
I don't have any experience in packaging software (that is, making it suitable for others to install and use easily). Although currently I'm the only one using it, I would like to know what is a good way to package it, so I can share it with others.
I want to package:
antlr generated Lexer+Parser for my language
code that wraps around the antlr-generated stuff
the antlr C runtime library.
How can I distribute all this as a translator for my language?
I remember that when I installed the C runtime library, stuff that was specific to my machine/OS was taken care of. (For example, how end-of-file is represented). Should I assume users of my translator have installed the C runtime separately?
Thanks,
-neha
You want to package it for.... what?
RPM (e.g. CentOS) read here: http://www.gurulabs.com/downloads/GURULABS-RPM-LAB/GURULABS-RPM-GUIDE-v1.0.PDF
For Debian: http://wiki.debian.org/HowToPackageForDebian
On OsX, package via homebrew: https://github.com/mxcl/homebrew/wiki/Formula-Cookbook
I am working on a large open source C++ program that uses the R standalone library (libRmath, Ubuntu/Debian package r-mathlib). I want to remove this dependency: I'd like to include the source code from the R standalone library in my source tree, without the entire R source code. Can this be done?
Unfortunately, the R standalone library seems tightly coupled to the rest of the R code. In the standard R source tarball, the same configure script is used for the main package and the standalone library. This configure script doesn't play well on different platforms. I am hoping that the standalone library is available as its own "standalone" source tree.
Related note: I've looked at the Rinside library, particularly via this thread. I think the method I am describing would make distribution easier, for 2 reasons: 1) users that already have R installed won't have to reconfigure their installation (and can maintain a different version as their default installation); 2) users without R won't have to install it.
Update: fixed a typo - I'd originally referred to Rinside as Rinclude
A few points for you:
Can this be done? Of course it can, just copy and paste the code for r-mathlib into your project. The licensing for that library is a very liberal LGPL. Now, is it a good idea? I don't think so. Shared libraries have upside in that you get bugfixes, easier and shorter build etc/
Seems tightly coupled to the rest of the R code. No, that is factually incorrect. The whole point of r-mathlib is that you can depend just on it. I think it may still needs R headers on your system but if you define the MATHLIB_STANDALONE variable. E.g., on my Ubuntu box I just did gcc -o /tmp/rmathTest /usr/share/doc/r-mathlib/examples/test.c -lRmath -lm and the resulting binary depends on libRmath alone, not libR.
Configure script doesn't play well on other platforms. That is a bold statement, don't make it anywhere near Prof Ripley. R is amazingly portable, and I fear your claim is a little lacking in empirical basics here.
What you are after can be done in different ways, and has been done in different ways.
And yes there is ample documentation as well. Start with 'Writing R Extensions' and 'R Admin + Inst' and by all means come back with follow-up questions.
Lastly, in case you change your mind and you do want R inside C++, you may want to consider RInside as well. That does however create a depedencies on R, Rcpp and RInside itself.
I would like to use the libLAS C/C++ library functions within R to import, analyse, export terrestrial lidar data. libLAS is a C/C++ library for reading and writing the very common LAS LiDAR format ( http://liblas.org/index.html ).
Would it be possible to use the Rcpp package to run this library (or other packages)? http://dirk.eddelbuettel.com/code/rcpp.html
Or should I compile and install it in order to use it following the compilation instructions http://liblas.org/compilation.html ? I am working on a MacOSx 10.6.5. As such I could also use it within Open Source GIS GRASS as described in the following wiki http://grass.osgeo.org/wiki/LIDAR#Micro-tutorial_for_LAS_data_import .
All advice is welcome related to reading and processing LIDAR data with R/GRASS.
Thanks,
Jan
For the question
Would it be possible to use the Rcpp
package to run this library (or other
packages)?
the answer is whopping Yup! as using it for glueing R to a given C/C++ library was pretty much the reason Rcpp was written for. Come and see the documentation and/or the rcpp-devel list for examples. There is some exciting new stuff happening with Rcpp modules but you can also get going the old-fashioned way of writing your wrapper. Rcpp makes mapping and R and C++ types (in both directions) a lot easier.