开发者

compiling livemedia as dynamic library: undefined references to virtual functions

I am trying to compile the livemedia libraries as a shared object, so I get the following .so:

  • libBasicUsageEnvironment.so
  • libgroupsock.so
  • libliveMedia.so
  • libUsageEnvironment.so

It seems to be good, but when I try to link against these libraries, I get a lot of errors of undefined reference to the virtual functions they use.

For what I understood so far, if in a class a virtual method is defined as

class MyClass
{
   ...
   virtual myMethod (int arg) {...};
   ...
}

the method is correctly found and linked, but if the code is split in a .h file

class MyClass

{
   ...
   virtual myMethod (int ar开发者_StackOverflow社区g);
   ...
}

and in a .cpp file

MyClass::myMethod (int arg)
{
...
}

it does not work any more.

Now, I admit I'm far from being a C++ guru, but why does this happen? Is it a bug of g++? Or is there some hidden feature of the language? If I compile it as a static library is works.


It is not a compiler bug. It indicates that the function definitions are found in the library .so rather than the header, which further implies that you are not linking correctly.


Maybe you're missing a -l (minus small L) switch in the linker command line to the library that contains the needed symbols.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜