Unix/Linux

Introduction

This page gives instructions about which libraries to use on Unix/Linux, and how to use them. But first, some background.

Background

On Unix, there are two kinds of libraries:

  • static, and
  • shared.

Static libraries normally end in ".a", while shared libraries normally end in ".so".

A library named "foo" will generally have a "lib" prefix, so it will be either:

  • libfoo.a (if static), or
  • libfoo.so (if shared)

How to link

What

When linking your application, you will need to pass a number of switches to the linker. How this is done depends on your compiler and/or linker.

Generally speaking, the -l switch tells the linker to link in a certain library. So -lfoo links in the foo library.

Most linkers will choose a shared library over a static one by default, so -lfoo will link in libfoo.so if it is present.

Where

In addition, the linker will need to know where to search for the libraries. Generally speaking, this is done with the -L switch. So

-L/usr/local/lib/emdros

will tell the linker to look in the /usr/local/lib/emdros directory.

LDFLAGS

The conventional way of doing this in Makefiles is to set the LDFLAGS variable to the string of switches that is necessary.

Order matters

The order in which you specify these options usually matters. Generally speaking, -L switches should come before -l switches, and dependent libraries should come before libraries on which they are dependent.

Which libraries to use

Always

You will always need the following library:

-lemdf

PostgreSQL

If using PostgreSQL, you will also need the following library:

-lpq

libpq is a PostgreSQL library.

MySQL

If using MySQL, you will also need the following library:

-lmysqlclient

In addition, you will probably need to tell the linker where to find the mysqlclient library. It is probably located in /usr/lib/mysql:

-L/usr/lib/mysql -lmysqlclient

In addition, you may find that libmysqlclient depends on libz. So you may need to do the following:

-L/usr/lib/mysql -lmysqlclient -lz

libmysqlclient is a MySQL library.

SQLite 2

If using SQLite 2, you will also need the following library:

-lsqlite_emdros

This library is found in the same directory as the other Emdros libraries, so there should be no need for extra -L flags.

SQLite 3

If using SQLite 3, you will also need the following library:

-lsqlite3_emdros

This library is found in the same directory as the other Emdros libraries, so there should be no need for extra -L flags.

BPT

If using the BPT engine, you simply follow the instructions that come with the BPT source code, then compile Emdros and link to the EMdF libary, since the BPT source code will be incorporated in the EMdF library.

MQL

If using MQL, you will need the follwoing libraries:

-lmql -lpcre_emdros

libmql depends on libemdf and libpcre_emdros.

Summary: PostgreSQL

If using PostgreSQL, you will need a string such as the following:

-L/usr/local/lib/emdros -lmql -lpcre_emdros -lemdf -lpq 

Summary: MySQL

If using MySQL, you will need a string such as the following:

-L/usr/local/lib/emdros -L/usr/lib/mysql -lmql -lpcre_emdros -lemdf -lmysqlclient 

Summary: SQLite 2

If using SQLite 2, you will need a string such as the following:

-L/usr/local/lib/emdros -lmql -lpcre_emdros -lemdf -lsqlite_emdros

Summary: SQLite 3

If using SQLite 3, you will need a string such as the following:

-L/usr/local/lib/emdros -lmql -lpcre_emdros -lemdf -lsqlite3_emdros

Previous:Which libraries to use
Up:Which libraries to use
Next:Windows