Re: Problem linking to wrong class

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

 



Brian Peschel <brianp@xxxxxxxxxx> writes:

>> One way around the issue is called ³early binding².  You could build
>> libtwo.so such that it binds to its own symbols, rather than allowing the
>> loader to resolve the unbound symbols with the ones provided by your
>> executable.
>>   
> Is there a way to force the compiler/linker to do this?

Use the -Bsymbolic linker option.


> From what I
> see doing a google search for early binding, I should already be doing
> it.  I am not using any function pointers here.  I have something like
> this in the shared library (libtwo.so), obviously, I have removed
> stuff:
>
> void something()
> {
>  TheQuery query;
>  query.doThis();
> }
>
> class TheQuery
> {
> private:
>  SqlQuery* query;
> public:
>  TheQuery()
>
>  void doThis() {query->runIt();}
> }
>
>
> class SqlQuery
> {
> private:
>  clear();
>  run();
>  stop();
> public:
>  SqlQuery();
>
>  void runIt() {clear(); run(); stop();}
> }
>
> But when it calls runIt() it is calling the one in the static (libone.a).

That is expected if the static library has a function named
SqlQuery::runit().  And if the static library does have such a function,
you've violated the One Definition Rule.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux