C++ shared objects

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Suresh369
    New Member
    • Sep 2006
    • 10

    C++ shared objects

    I have written a program which inherits a calss from a different shared object. I have linked that shared object when I compile my program using the -shared <path>/blah.so

    My question is how exactly do I include the parent class in my program. When I tried to use

    #include<parent .h>

    class child : public parent {

    }

    the compiler complains. The class parent is in blah.so which I am linking.

    Please help
  • tyreld
    New Member
    • Sep 2006
    • 144

    #2
    What exactly does the compiler complain about? The actual compiler message would be helpful in determining what might be the problem. Have you told the compiler where to find the include file? If it isn't in the working directory or the default include path it won't be found.

    Comment

    • Suresh369
      New Member
      • Sep 2006
      • 10

      #3
      Originally posted by tyreld
      What exactly does the compiler complain about? The actual compiler message would be helpful in determining what might be the problem. Have you told the compiler where to find the include file? If it isn't in the working directory or the default include path it won't be found.
      OK, I admit I dont know anything abt linking. This is the question I have.

      Say I just have the .so file of another C++ program and dont have access to the source code (.h or .cpp). How do I inherit a class in my current program just by linking the .so file?

      First of all, is it possible?

      This is the situation I was in in the above post.

      I tried to compile my program using :
      g++ -shared <path>/parent.so ..... (where parent.so is the shared object)

      Am I right with the command line?

      Comment

      • tyreld
        New Member
        • Sep 2006
        • 144

        #4
        You can't. You need the ".h" or ".cpp" file that contains the class definition you want to inheiret from just to compile your existing code into an object file.

        Comment

        • soharto
          New Member
          • Oct 2006
          • 2

          #5
          Originally posted by Suresh369
          I have written a program which inherits a calss from a different shared object. I have linked that shared object when I compile my program using the -shared <path>/blah.so

          My question is how exactly do I include the parent class in my program. When I tried to use

          #include"parent .h"

          class child : public parent {

          }

          the compiler complains. The class parent is in blah.so which I am linking.

          Please help
          i hope it will work but this is the key idea to solve it

          Comment

          Working...