Installing C libraries

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
PanchoVilla

Installing C libraries

Post by PanchoVilla »

Hi

I'm new to Linux and already finding it better than that other OS in many ways :) . Finding that I want to install some open source libraries to use with C. Never really had to do this before since in VS I never needed any extra libraries, and not famiiliar with the directory structure :? . My questions:

1. How can I be sure whether a library is already installed ?

2. Where should new libraries live? It looks like

Code: Select all

/usr/include
?

3. In particular I'm looking to install g2 :
http://g2.sourceforge.net/
which asks that I first install gd :
http://www.libgd.org/releases/
which in turn indicates that I first have to get installed:
zlib, available from http://www.gzip.org/zlib/
Data compression library
libpng, available from http://www.libpng.org/pub/png/
Portable Network Graphics library; requires zlib
FreeType 2.x, available from http://www.freetype.org/
Free, high-quality, and portable font engine
JPEG library, available from http://www.ijg.org/
Portable JPEG compression/decompression library
However, it turns out according to software/package mgr that I already have got something called zlib1g. Does this mean that I already have zlib and don't need to do anything about it?

4. These tend to have installation instructions that go something like
From a released source, use:
1. Type './configure'
2. Type 'make install'
Is this the right way in Mint?

5. Well you can see I'm a confused newbie, so any other advice on this subject welcome.

fyi, system in use, not that it's really relevant:
amd 2-core chip 5.6GHz, dual boot Mint Isadora / Windows XP via grub, separate HDDs.

So far tried using geany and wrote Hello World ... that's as far as I've got. Going to try anjuta.

I appreciate the general sentiment of "try things out, cluck up your install" but I'd prefer not to cluck things up if I can avoid it. I already tried installing OpenOffice last night, not realising it came pre-installed, and that install failed because it didn't find things in /bin for some reason even though they were there, so it wasn't very encouraging.

Cheers in advance for your help.

Warwick
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Kendall

Re: Installing C libraries

Post by Kendall »

See if this works for you: g2_0.72-1_i386.deb. Keep in mind that the source is over three and a half years old and is likely a bit outdated.
PanchoVilla

Re: Installing C libraries

Post by PanchoVilla »

Thanks. I tried it.

Package installer says to me "wrong architecture - i386"...
PanchoVilla

Re: Installing C libraries

Post by PanchoVilla »

Update: I now did the following (and so far it does not work):

1. In package manager, installed zlib1g-devel and libpng12-dev
2. Got gd-2.0.35 from interweb. Navigated to directory as root, typed
./ configure
make install
[it seemed to work].
3. In package manager, got libg2-dev and libg20 . Not sure whether this worked since the structure in /usr/include does not look the same as what I get from g2-0.72.tar.gz from sourceforge. So tried instead following the installation instructions and installing on terminal from downloaded files.
3a. It tells me X11 is not going to work, so I install libx11-dev in Software Manager to get this functionality, and repeat. It now says that PNG and X11 are going to work.
Other than that, nothing seemed to change compared to the package mgr install - still no gd directory appears, the .h files all live in /usr/include .

In Anjuta, I then go to run a simple program:

Code: Select all

#include <stdio.h>
#include <g2.h>
#include <g2_gd.h>
#include <g2_X11.h>

int main()
{
	int d;
	 d=g2_open_X11(50,50);
	 g2_line(d,5,5,45,45);
	 g2_circle(d,25,25,20);
	 getchar();
	return 0;
}
But this gives me
main.c:30: undefined reference to 'g2_open_X11'
main.c:31: undefined reference to 'g2_line'
main.c:32: undefined reference to 'g2_circle'

I then tried

Code: Select all

#include <stdio.h>
#include "/usr/include/g2.h"
#include "/usr/include/g2_gd.h"
#include "/usr/include/g2_X11.h"

int main()
{
	int d;
	 d=g2_open_X11(50,50);
	 g2_line(d,5,5,45,45);
	 g2_circle(d,25,25,20);
	 getchar();
	return 0;
}
However, the result is the same. No idea why though, it's clear that it should at least read the function declarations where they live in g2_gd.h and so on, even if nothing else worked.
Kendall

Re: Installing C libraries

Post by Kendall »

Considering it hasn't been maintained in three and a half years, it possible that it's antiquated and it's functionality can be reproduced using something else.

Also when installing from source I was of the opinion that you should use the following:

Code: Select all

./configure
make
make install
I can't recall off the top of my head as it's been a very long time since I installed from source (I package everything now before installing).
PanchoVilla

Re: Installing C libraries

Post by PanchoVilla »

I'm pretty sure g2 functionality can be reproduced with openGL or other things nowadays, but I don't need anything fancy, only want to make basic plots in my programs.
Thanks for advice about installing - I was hoping this was the right way (well, some of these things have an extra step like "make depend" but anyway it seemed to work - or so it claimed).

How do you set up your projects when you are using g2? Do you have to do anything special to make it work, rather than just #include?
Locked

Return to “Beginner Questions”