03-17-07 12:29 PM
On Mar 17, 4:18 pm, "ioan" <niciodata...@gmail.com> wrote:
> //A.h
> #ifndef H_A_H
> #define H_A_H
> class A {
> public:
> int SecretMessage ();};
>
> #endif
> // A.cc
> int A :: Message () {
> return 6001;}
>
> // Client.cc
> #include "./A.h"
>
> #include <iostream>
> using namespace std;
>
> int main () {
> A a;
> cout << a.SecretMessage () << endl;
> return 0;}
>
> // end of files
>
> ###########################
> # Compile & Use #
> ###########################
> $ g++ -g -shared A.cc -o libA.so
> $ g++ -g -L. -lA Client.cc -o Client
> $ ./Client
>
> $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
> $ Motivation $
> $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
>
> I tried to export "classes" from so (shared objects),
> but as a newby to gcc compiler tools I made mistakes.
> Here is what I learn and I'd like to share:
> 1. libA.so is important to have "lib" suffix at libA.so build time.
> 2. Client code is linked with libA.so using -L<path to libA.so> -lA
> Notice "libA.so" --> "A" at build time for Client code.
>
> Happy coding.
Good, but this is not a group for C++, this is for unix. I can't
figure whats your post has any relation to this topic.
[ Post a follow-up to this message ]
|