473,659 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a shared library and loading it

Hi ,

I am trying to create a shared library and trying to load it
usinf dlopen() function . My code and steps to create and load the *.so
is :

/*** test.c ***/
#include <stdio.h>
void test()
{
printf("Hello World\n");
}

/*** Steps for *.so creation ***/
bash-3.00# gcc -fPIC -c test.c
bash-3.00# gcc -o library.so -shared test.o
bash-3.00# gcc -o library.so -Wl,-h,library.so -shared test.o

/***load.c***/
#include <stdio.h>
#include <dlfcn.h>

int main(int argc,char **argv)
{
void *handle;
char *error;

handle = dlopen ("library.so ", RTLD_LAZY);
if (!handle) {
fprintf (stderr, "%s\n", dlerror());
exit(1);
}

}

/*** Steps for creating load executable***/
bash-3.00# gcc test.c -ldl

When I run the "a.out" it gives me the following error

bash-3.00# ./a.out
ld.so.1: a.out: fatal: library.so: open failed: No such file or
directory

Can someone tell me .. where I am wrong ?

Thanks !

Aug 26 '06 #1
0 1169

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2593
by: Francisco Miguel Montenegro Montes | last post by:
Hi, perhaps some of you can help me... I'm installing Python 2.3 (in Linux RedHat 8.0) and I need to build it like a shared library, because I want to interact Python with PostgreSQL. Following the README instructions, I try: ../configure --enable-shared --prefix=/whatever (I'm not root of my system, so I can't use /usr/local/) make make install
2
3394
by: Douglass Turner | last post by:
Hi, Please release me from my own private hell. Platform: SuSE 8.1 I'm installing python 2.3 tarball as follows: ../configure --enable-shared make
3
2601
by: Rickard Lind | last post by:
Is there any way to build the python executable statically and still be able to load modules built as shared libraries? I'm trying to run python scripts on a stripped down FreeBSD (4.9) machine which has no shared system libraries so I want to link it statically against libc et al, but it would be nice to still be able to load modules which were built as shared libraries. In particular I have a library for which I've generated a wrapper...
2
2706
by: Brad Wood | last post by:
Using VS2003, I can't add an existing class to a project w/o the IDE creating a copy of it. I want multiple projects to be able to share a central copy of a class. I can't compile the shared class into a library because one of the executables that uses the class needs to be a self contained executable that will be downloaded and immediately executed on a PDA. I can't GAC the shared library so that both applications can use it because...
6
14843
by: Jeff | last post by:
Hi - I understand how to create a directory folder, but how can I programatically create a _shared_ directory folder and set its permissions?? (I'm using VB.NET.) Thanks for your help. - Jeff
7
3390
by: akennis | last post by:
First of all, sorry for duplicating this post. I put it up in the alt.comp.lang.learn.c-c++ mistakenly. I'm investigating a problem whereby exceptions thrown from functions in a Shared Library which was dynamically loaded (dlopen) are not properly caught by the caller. Specifically, when compiling with G++ version 4.0, the RTTI data associated with the exception types is not being properly aligned between the Shared Library and its...
3
2514
by: abhi147 | last post by:
Hi , I am trying to create a shared library and trying to load it usinf dlopen() function . My code and steps to create and load the *.so is : /*** test.c ***/ #include <stdio.h> void test() {
3
2540
by: ragi | last post by:
Hi Friends, Could you please tell me about, 1. What a shared library in c contains 2. (.a) file extension for shared libraries. 3. Is shared libraries are reentrant. Thanking you in advance,
3
3269
by: Bala | last post by:
Hello, I am trying to create a shared library on solaris. The inputs to this library is a source file and then 2 static libraries. I need to call code within the shared library in another application which in turn will use the static libraries for further processing. This is the command i am using to build the shared library
1
1824
by: twdo | last post by:
OK. I am totally frustrated here. I have a setup project within Visual Studio. That setup project is calling a class library project by the use of Custom Actions. Within that class library (my "helper" project), I have an installer class. That class is called by Install, Uninstall, Rollback, etc. I am only using Install and Uninstall. During the installation of my application, I want to create a UNC network share named TRM, pointed to the...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.