LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-12-2001, 06:26 AM   #1
michalbella
LQ Newbie
 
Registered: Nov 2001
Distribution: rh
Posts: 1

Rep: Reputation: 0
Talking loading modules for running programs


I want to load a library while the program is running, something like in linux-kernel (loading modules); (C/C++ under RH/Linux)
does anybody "know how" ?
 
Old 11-12-2001, 01:31 PM   #2
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
well.. if it's a kernel module, then you use insmod to load it. if you're talking about a library, then it needs to be dynamically linked against a program at compile time to be loaded during runtime.
 
Old 11-12-2001, 04:49 PM   #3
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Try this example:

Code:
/* test.h */

void test();
Code:
/* test.c */

#include <stdio.h>
#include "test.h"

void test()
{
   printf("Hello dude");
}
Code:
/* loadtest.c */

#include <stdio.h>

#include "test.h"

main()
{
   test();
}
Build Commands:
Code:
# pwd
/home/whatever/src/shared
# cc -c -shared test.c
# cc -shared -W1,-soname,libtest.so -o libtest.so test.o
# cc loadtest.c -o loadtest -L. -ltest
# export LD_LIBRARY_PATH=/home/whatever/src/shared
# ./loadtest
Hello dude
Hope this helps. Hope this works...

Gary
 
Old 11-12-2001, 04:55 PM   #4
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Quick test:
Code:
# mv libtest.so libtest.dude
# ./loadtest
./loadtest: error in loading shared libraries: libtest.so: cannot 
open shared object file: No such file or directory
# mv libtest.dude libtest.so
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Modules knoxlinuxuser Linux - Newbie 3 04-02-2005 10:59 AM
Loading modules error after loading compiled kernel td0l2 Linux - Newbie 12 07-28-2004 11:10 AM
modules are loading that shouldn't in my rc.modules thrice Slackware 3 05-11-2004 10:35 PM
loading modules w/o rc.modules e1000 Slackware 3 01-09-2004 02:57 AM
Loading Modules Mega Man X Linux - Newbie 6 06-05-2003 05:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration