Contents:
Search: |
Unix/LinuxIntroductionThis page gives instructions about which libraries to use on Unix/Linux, and how to use them. But first, some background. BackgroundOn Unix, there are two kinds of libraries:
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:
How to linkWhatWhen 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. WhereIn 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. LDFLAGSThe conventional way of doing this in Makefiles is to set the LDFLAGS variable to the string of switches that is necessary. Order mattersThe 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 useAlwaysYou will always need the following library: -lemdf PostgreSQLIf using PostgreSQL, you will also need the following library: -lpq libpq is a PostgreSQL library. MySQLIf 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 2If 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 3If 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. BPTIf 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. MQLIf using MQL, you will need the follwoing libraries: -lmql -lpcre_emdros libmql depends on libemdf and libpcre_emdros. Summary: PostgreSQLIf using PostgreSQL, you will need a string such as the following: -L/usr/local/lib/emdros -lmql -lpcre_emdros -lemdf -lpq Summary: MySQLIf 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 2If 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 3If using SQLite 3, you will need a string such as the following: -L/usr/local/lib/emdros -lmql -lpcre_emdros -lemdf -lsqlite3_emdros |