Accessing libraries written in OCaml and C++ from Ruby code - c++

I'm writing a Ruby program and I want to use the following libraries in it:
LTL3 tools
AT&T FSM library
LTL2BA library
LTL3 tools are written in OCaml, AT&T FSM library is written in C++, LTL2BA library is written in C++. LTL3 tools have dependencies on AT&T FSM library and LTL2BA library. I have both executables and source code for all those libraries.
How can I access all these libraries from Ruby code? Sorry for noob question, it's my first week in Ruby. BTW I'm using Linux Ubuntu if that helps.

The simplest way to interact with a library written in a different language is not to find an API bridge to make it run as part of your program, but to have it run as a different process to which you pipe data (in text format, or whatever it easily supports).
From the description, L3LTools seems to be used for converting some sort of stuff into another sort of stuff, and it can read and print them in a documented textual format, and there is a shell script wrapper that does the plumbing for you.
You don't even need to know in which language it's written in. Just get a parser for its output format, a printer for its input format, and call the script from your code.

Related

How can I get a .pdf's article abstract into my C++ program

I was searching for some ways to read .pdf files and I wasn't able to get anything from it, I would probably need a library but all the options I found is very confusing and hard to deal with.
I was wondering which way would be the best way for me to do this task, which is to search through the .pdf and get the content in the Abstract section of it. (which is text)
The easiest and cheapest is using an open source library which is popular and known to other programmers.
Before trying to write your own PDF reader from scratch, take look at these:
Parsing:
PoDoFo
The PoDoFo library is a free, portable C++ library which includes
classes to parse PDF files and modify their contents into memory. The
changes can be written back to disk easily. The parser can also be
used to extract information from a PDF file (for example the parser
could be used in a PDF viewer). Besides parsing PoDoFo includes also
very simple classes to create your own PDF files. All classes are
documented so it is easy to start writing your own application using
PoDoFo.
Generating:
LibHaru
Haru is a free, cross platform, open-sourced software library for
generating PDF written in ANSI-C. It can work as both a static-library
(.a, .lib) and a shared-library (.so, .dll).
panda
A PDF generation API written in C

How to package a parser generated with Antlr

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

Scripting C++ with python

I have a C++ program and I want to implement scripts on it. The desired scenario is, I have an executable of c++ code, it then calls at specific times a python script so it knows what to do through the embeded interpreter and the script then uses some form of API from the c++ program. This is where I ran into a problem. To expose c++ code to python you need to compile a DLL of the wrappers that you want and load it as a module inside python and that breaks my intention of python accessing the executable's functions.
Any way to resolve this problem without resorting to put so much pieces of c++ on a shared library?
What you want to do is to embed Python code into your application. There is an article on python.org on how to do that using raw CPython, but it's not that exhaustive when it comes to C++. A better bet might be to use Boost.Python or SWIG.

parser for c++ headers to extract functions with standard linux tools?

Is there something like this? I need to extract C++ functions from header files with all the parameters they use. It would be nice if i can use standard Linux programs
You can use understand 4 C++ which is a front end tool that browse your source code and generate metrics for your source code. It also has a powerful API that allows you to write your own static analysis tools. So far understand works on windows, and a bunch of other linux based OS's. Though I've only used the windows based API.
It is found at:
http://scitools.com/

Lisp Executable

I've just started learning Lisp and I can't figure out how to compile and link lisp code to an executable.
I'm using clisp and clisp -c produces two files:
.fas
.lib
What do I do next to get an executable?
I was actually trying to do this today, and I found typing this into the CLisp REPL worked:
(EXT:SAVEINITMEM "executable.exe"
:QUIET t
:INIT-FUNCTION 'main
:EXECUTABLE t
:NORC t)
where main is the name of the function you want to call when the program launches, :QUIET t suppresses the startup banner, and :EXECUTABLE t makes a native executable.
It can also be useful to call
(EXT:EXIT)
at the end of your main function in order to stop the user from getting an interactive lisp prompt when the program is done.
EDIT: Reading the documentation, you may also want to add :NORC t
(read link). This suppresses loading the RC file (for example, ~/.clisprc.lisp).
This is a Lisp FAQ (slightly adapted):
*** How do I make an executable from my programme?
This depends on your implementation; you will need to consult your
vendor's documentation.
With ECL and GCL, the standard compilation process will
produce a native executable.
With LispWorks, see the Delivery User's Guide section of the
documentation.
With Allegro Common Lisp, see the Delivery section of the
manual.
etc...
However, the classical way of interacting with Common Lisp programs
does not involve standalone executables. Let's consider this during
two phases of the development process: programming and delivery.
Programming phase: Common Lisp development has more of an
incremental feel than is common in batch-oriented languages, where an
edit-compile-link cycle is common. A CL developer will run simple
tests and transient interactions with the environment at the
REPL (or Read-Eval-Print-Loop, also known as the
listener). Source code is saved in files, and the build/load
dependencies between source files are recorded in a system-description
facility such as ASDF (which plays a similar role to make in
edit-compile-link systems). The system-description facility provides
commands for building a system (and only recompiling files whose
dependencies have changed since the last build), and for loading a
system into memory.
Most Common Lisp implementations also provide a "save-world" mechanism
that makes it possible to save a snapshot of the current lisp image,
in a form which can later be restarted. A Common Lisp environment
generally consists of a relatively small executable runtime, and a
larger image file that contains the state of the lisp world. A common
use of this facility is to dump a customized image containing all the
build tools and libraries that are used on a given project, in order
to reduce startup time. For instance, this facility is available under
the name EXT:SAVE-LISP in CMUCL, SB-EXT:SAVE-LISP-AND-DIE in
SBCL, EXT:SAVEINITMEM in CLISP, and CCL:SAVE-APPLICATION in
OpenMCL. Most of these implementations can prepend the runtime to the
image, thereby making it executable.
Application delivery: rather than generating a single executable
file for an application, Lisp developers generally save an image
containing their application, and deliver it to clients together with
the runtime and possibly a shell-script wrapper that invokes the
runtime with the application image. On Windows platforms this can be
hidden from the user by using a click-o-matic InstallShield type tool.
Take a look at the the official clisp homepage. There is a FAQ that answers this question.
http://clisp.cons.org/impnotes/faq.html#faq-exec
CLiki has a good answer as well: Creating Executables
For a portable way to do this, I recommend roswell.
For any supported implementation you can create lisp scripts to run the program that can be run in a portable way by ros which can be used in a hash-bang line similarly to say a python or ruby program.
For SBCL and CCL roswell can also create binary executables with ros dump executable.
I know this is an old question but the Lisp code I'm looking at is 25 years old :-)
I could not get compilation working with clisp on Windows 10.
However, it worked for me with gcl.
If my lisp file is jugs2.lisp,
gcl -compile jugs2.lisp
This produces the file jugs2.o if jugs2.lisp file has no errors.
Run gcl with no parameters to launch the lisp interpreter:
gcl
Load the .o file:
(load "jugs2.o")
To create an EXE:
(si:save-system "jugs2")
When the EXE is run it needs the DLL oncrpc.dll; this is in the <gcl install folder>\lib\gcl-2.6.1\unixport folder that gcl.bat creates.
When run it shows a lisp environment, call (main) to run the main function
(main).