Hi,
I am trying to compile a simple shared library on my linux box. I m running RHEL 5.
This is the code for the lirary file
//-----------------libhello.c---------
#include <stdio.h>
void sayhello(){
printf("library saying hello!!
\n");
}
this is the header file
//--------------libhello.h------
//declaring the functions!!
void sayhello();
I have compiled the header source file as
gcc -fPIC -c -o libhello.o libhello.c
and then, to make it a shared library,
gcc -shared -Wl,-soname,libhello.so.1 -o libhello.so.1.0.0 libhello.o
my PWD: /home/harsha/lib
then I used ldconfig as
/sbin/ldconfig -v -n . (output shown below)
.:
libhello.so.1 -> libhello.so.1.0.0
and I have set the LD_LIBRARY_PATH env var as
export LD_LIBRARY_PATH=/usr/harsha/lib
now I wrote a simple program to used the above created shared library
//--------------hello.c-----------------
#include "libhello.h"
int main(void)
{
sayhello();
}
and compiled as
gcc -c -o hello.o hello.c
now when I try to link the above object file and the shared library I am facing this error..
gcc -o dynamic_out hello.o -L. -lhello
/usr/bin/ld: cannot find -lhello
collect2: ld returned 1 exit status
the soname link has been created by the ldconfig and somehow this error is showing up..