Library installation in linux

Libraries have been installed in:
/usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.



Most of time, I have been adding the path to the /etc/ld.so.conf and doing ldconfig. Need to understand the other options.

Re: Assignment for July 19

Senthil wrote :
> Write a Linked List Program in C and C++.
> Single Linked List only.
>
/* Linked List program. A very simple one to understand the basics */

#include<stdio.h>
#include<stdlib.h>

struct node {
int data;
struct node* next;
};

int main(int argc,char **argv)
{

struct node* head=NULL;
struct node* second=NULL;
struct node* third=NULL;

head=malloc(sizeof(struct node));
second=malloc(sizeof(struct node));
third=malloc(sizeof(struct node));

head->data=1;
head->next=second;

second->data=2;
second->next=third;
third->data=3;
third->next=NULL;

return 0;

}

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

/* Linked List Program in C Plus Plus */
#include<iostream>
using namespace std;

class list
{
private:
struct node {
int data;
struct node *next;
};
struct node *head,*first,*second;
public:
list();
~list();
void addnode();
};

list::list()
{
head=NULL;
first=NULL;
second=NULL;
}

list::~list()
{
while(head != NULL)
{
node *temp;
temp=head;
head=head->next;
delete temp;
}
}

void list::addnode()
{
head=(node *)malloc(sizeof(struct node));
first=(node *)malloc(sizeof(struct node));
second=(node *)malloc(sizeof(struct node));

head->data=1;
head->next=first;

first->data=2;
first->next=second;

second->data=3;
second->next=NULL;
}

int main(int argc,char **argv)
{

list listobj;
listobj.addnode();
}

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Observations:
- Struct node * head,first,second; does not serve the purpose. Either
they should as in the first program or as in the second program
- Allocation of memory, the first program accepted without typecasting
to (node *) whereas the second cpp program did not.

--
O.R.Senthil Kumaran
http://uthcode.sarovar.org

Unix Blog

http://unixblog.port5.com/
where I plan to put my unix learnings while working from home. Coz, I need to do ftp/rsync from the shell where the local unixblog folder will be present.

Its powered by Nanoblogger.
If you have a Unix Machine online, give it a try.