Why do we need development version of libraries to compile against? - compilation

Dirk said
This is the mother of all development FAQs: you need package libfoo to
run code against foo, and package libfoo-dev to compile against foo.
I wonder why?
What are different between libfoo-dev and libfoo?
Thanks!

Examples, man files and header files.
Examine https://packages.debian.org/sid/i386/zlib1g-dev/filelist and https://packages.debian.org/wheezy/i386/zlib1g/filelist for an example.

Related

Can Elixir or Erlang programs be compiled to a standalone binary?

It says that Elixir has a tool called elixirc and Erlang has a tool called erlc to compile modules for use. It says immediately after this that you can then run code with the elixir command line tool.
Is there a way to compile a binary executable with Elixir or Erlang? (one which I can chmod +x binary_name and then run from the same directory with ./binary_name)
Escripts support that to some extent but you still need Erlang installed in your machine. See this answer for more information: Elixir or Hex portable package format?
Make sure you checkout Distillery. It does what you need, without having to deal with Rebar.
Add this to your mix.exs file's dependencies then run mix release.
defp deps do
[{:distillery, "~> 0.9"}]
end
Their documentation is great:
Home - Distillery Documentation
You can use tools like rebar to generate a release that also contains the erts, which makes it possible to run said release on a machine where erlang is not installed. But the erts included corresponds to the operating system on which the release was built, i.e. windows binaries if built on windows.
You can use Elixir's built-in releases as of Elixir 1.9. It is a lightweight alternative to Distillery.
Caveats:
It will not create anything remotely like Go does with a single binary executable that you can run almost anywhere. Also your target will have to match the CPU architecture and OS.
To build a release run:
mix release
Read more here:
https://hexdocs.pm/mix/Mix.Tasks.Release.html
There are a few tools now that allow you to create a self contained executable binary that doesn't require any dependencies on the target machine. They support multiple platforms.
Bakeware: https://github.com/bake-bake-bake/bakeware
Burrito: https://github.com/burrito-elixir/burrito

Compiling and embedding lua into a C++ application

For portability reasons, I'd like to compile lua from source when I compile my C++ code. I use lua to read input file.
If I understand correctly, lua's readme mentions that it's possible to do that through src/Makefile. I can't really read it that well. Has anyone figured out how to do it?
is it possible to have it in one command? gcc ....
bonus: how to put it in cmake ?
Lua has a makefile that needs your target platform to build to so you will need to specify make [target platform].
But that is right in the beginning of the readme.
You could try to call the make command from inside your build process.
Cheers
[UPDATE based on the comments]
If you use:
make a PLAT=[target platform]
on the command line in the src directory it will only build the liblua.a library for the target platform then you will just need to copy that file to wherever you need and link against it.

Running or modifying the source code(binaries) that are available under GNU General public license

Dear stackoverflow members,
I have a question that might sound silly to most of the members here, but it is bothering me for quite a while now and couldn't find any appropriate answer for it, yet.
My question is, how can we run a source code or binary of a open source project which is distributed under GNU license.
When I download the project, all I get is a .tar file, when unzipped, I get a folder containing many sub-folders, like src, build and etc. This folder looks similar to the project folder created by an IDE like netbeans. But how can I compile and modify these source file?
Is there an application that does it? or do i have to switch to linux to do it?
I am currently using a copy of windows 7 and also have a copy of windows xp at disposal.
Any help would be very much appreciated.
Thank you very much in advance.
cheers
Kishore.
Under GNU and GNU/Linux distros the packages are installed by the package manager (e.g. no need to build or download anything). Some programmers distribuite (along with the source code) binary versions of the program (which you run by clicking on them, or by invoking them from the command line). You can compile source code on Windows thanks to MinGW. For the istructions to run read the `README' file that you find in the unpacked dir. Most programs can be build with:
./configure; make; make install
If you post the link to the project I could help you with the building process.

Checking for c library

What is the best method in bash to check to se if a c library is installed?
Per comments, to be more clear:
I run an install script that looks for the libexpat header file (expat.h)
Currently it is doing this via:
if ! locate libexpat.so 1> /dev/null; then
However, it should be looking for expat.h, but this still required the mlocate db to be updated first.
Any better way?
You can do as autoconf does (or, more accurately, configure scripts generated by autoconf do), and test whether you can compile a C program that uses the library.
If you don't have a compiler or the development tools installed, your options are more limited.
It also isn't clear whether you want to search in out of the way locations for the library, or if you are only concerned with it being installed in the main library directories. Also, are you looking only for shared libraries, or are you looking for static libraries - the naming conventions differ wildly depending on what you're up to, and which machine type you are doing it on (Linux and Solaris vs AIX vs MacOS X vs HP-UX (older, for PA-RISC) vs Windows, for instance). If you're looking for static libraries, you'll be hard-pressed to use them without the compiler (and probably the headers). If you're looking for shared libraries, you can use those without the development paraphernalia if you compile the program on some other machine and copy it to the target machine.
The best one I found was with #cnicutar's comment, thanks.
Specifically to do this in a bash script:
expat_loc=`whereis -b expat.h | cut -c8-`
if [[ -e "$expat_loc" ]]; then
#Something something
fi;
If you need runtime, you'll need a specific version for running some stuff. Try to run that stuff.
If you need headers, try to compile something.

Help on installing a library like libical into Xcode

I would like to use the libical library in my project, but I have never used an external library before. I have downloaded the libical files, but I am pretty much stuck there. I do not how how, or even if, I need to build/extract them and then how to get them into Xcode. Any help would be greatly appreciated. Thank you.
If this a pre-built library then you can just drag it into your Xcode project (or use Project => Add to Project…) in the same way that you would for source/header files.
If it's not pre-built then you'll need to build it for whatever environments and architecture you want to target. If it comes with an Xcode project then this is easy. If it's just the usual open source type of distribution then you usually do something like this:
$ ./configure
$ ./make
$ sudo ./make install
That will typically put the built library(ies) and header(s) into somewhere like /usr/local/lib and /usr/local/include. In your main Xcode project you can then just add these header(s) and library(ies) to your project.
Note that if you're cross-compiling, e.g. for iPhone, then you'll need to add some flags to the ./configure command so that you target the correct architecture, e.g. ./configure -build=arm-apple-darwin9.0.0d1.
Note also that it's usually a good idea to check MacPorts to see if they have already fixed up a given open source project for Mac OS X - this can save you a lot of work.
See also this blog about building and using libical on iPhone.
Getting libical to configure and build for arm is more tricky then ./configure -build=arm-apple-darwin.
See this question and answer for more details: Compiling libical

Resources