help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shared object linking problem


From: Ulrich Eckhardt
Subject: Re: Shared object linking problem
Date: Mon, 21 Nov 2005 07:19:51 +0100
User-agent: KNode/0.9.2

[nothing to do with GCC, dropping that from the list of NGs]

izhar.wallach@gmail.com wrote:
> Thus, I was thinking of using a shared object for that component.
> However, in the example below, I haven't figured out a way to modify
> commonClass.cpp (for example, the print() method) and be able to see
> the changes without rerunning  the application. I can see changes made
> directly in sharedClass.cpp, though. 

Let's see:

> commonClass.o: commonClass.cpp
>         g++ -Wall -c commonClass.cpp
> sharedClass.o: sharedClass.cpp commonClass.o
>         g++ -Wall -c sharedClass.cpp
> sharedClass.so: sharedClass.o
>         g++ sharedClass.o -shared -o sharedClass.so
> main.o: main.cpp
>         g++ -rdynamic -Wall -c main.cpp
> 
> main: main.o commonClass.o
>         g++ -rdynamic main.o commonClass.o -ldl -o main

commonClass is linked directly into the main executable, so there is no way
to change it at runtime. sharedClass is loaded dynamically, so it could be
replaced by another at runtime.

> Is there a way to see changes in commonClass.cpp without restarting 
> the application? 

No, unless you structure it like sharedClass, that is.

Uli


-- 
http://gcc.gnu.org/faq.html
http://parashift.com/c++-faq-lite/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]