08.02.2014 Views

How to Use External Libraries with Anjuta

How to Use External Libraries with Anjuta

How to Use External Libraries with Anjuta

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BIOL 5200: Fall 2004 Modeling Biological Systems J. Haefner<br />

<strong>How</strong> <strong>to</strong> <strong>Use</strong> <strong>External</strong> <strong>Libraries</strong> <strong>with</strong> <strong>Anjuta</strong><br />

version 0.3: September 14, 2004<br />

Introduction<br />

A library is a collection of binary, compiled files that provide some function. For example, you have already<br />

used a library of files when you use the input/output functions of standard C. Being compiled, you can not<br />

edit or alter the code. This is often a bad thing; but, on the other hand, you don’t have <strong>to</strong> compile or<br />

debug the code. Hopefully, the author has found all the bugs before creating the library. Generally, the<br />

files included in the libraries are not complete, stand-alone programs. Rather they are simply code that has<br />

been compiled but not linked <strong>with</strong> other code <strong>to</strong> create an executeable file. Usually, they have no main()<br />

function. (You supply that when you create a program that uses the libraries.)<br />

There are two problems associated <strong>with</strong> using these libraries. First, you have <strong>to</strong> know where they are so<br />

that you can instruct the compiler how <strong>to</strong> include them in your project or program. Second, the libraries are<br />

composed of functions that take arguments and return or change values. To properly invoke these functions,<br />

you have <strong>to</strong> know how <strong>to</strong> use the so-called API (Application Programmer’s Interface). This knowledge is<br />

imparted <strong>to</strong> you by means of something called “documentation.”<br />

Setting-Up anjuta <strong>to</strong> <strong>Use</strong> <strong>Libraries</strong><br />

After you create a project, tell the compiler and linker where you want them <strong>to</strong> look for files.<br />

1. On <strong>to</strong>p menu bar, select Settings. A drop-down menu appears <strong>with</strong> items including:<br />

• Compiler and Linker Settings . . .<br />

• Source Paths . . .<br />

• Commands . . .<br />

• . . .<br />

Select Compiler and Linker Settings . . . , and the following window appears.<br />

2. Click on the tab labeled Include Paths<br />

In the editing field, type in the following and after each, click on Add:<br />

• ../include<br />

–1–


BIOL 5200: Fall 2004 Modeling Biological Systems J. Haefner<br />

• /usr/local/dislin<br />

• /usr/local/share/MBS<br />

The order does not matter. When all have been entered, click Update<br />

The window should look like this:<br />

3. Select Library Paths. In the editing field type and after each add the following paths:<br />

• /usr/local/share/MBS<br />

• /usr/local/dislin<br />

Then click Update.<br />

The window should look like this:<br />

4. Select <strong>Libraries</strong>. In the editing field, type in the following and after each, click on Add:<br />

• xyplot<br />

• dislnc<br />

• gsl<br />

• gslcblas<br />

–2–


BIOL 5200: Fall 2004 Modeling Biological Systems J. Haefner<br />

The first 2 are libraries needed for plotting. The last 2 are GSL numerical methods libraries. We’ll use<br />

these again in the near future.<br />

Click Update,<br />

The window should look like this:<br />

Then Click Close. You may then see the following window:<br />

Click No.<br />

If you mess this up by clicking Yes, go <strong>to</strong> the <strong>to</strong>p-level drop-down menu bar and do:<br />

Build → Au<strong>to</strong> Generate ...<br />

<strong>Anjuta</strong> will then reconstruct your project files; it will take a few seconds.<br />

Save your project: these settings will be s<strong>to</strong>red. Compile and build as in the past. If you create a new<br />

project using these libraries, you will have <strong>to</strong> repeat the process.<br />

–3–

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!