[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: linking a C++ lib to an objc tool.
From: |
David Chisnall |
Subject: |
Re: linking a C++ lib to an objc tool. |
Date: |
Sun, 27 Aug 2017 09:05:10 +0100 |
Most of the code that I’ve written recently using GNUstep has been
Objective-C++, so I can confirm that this work well (though I’m not using gcc,
where I believe Objective-C++ still has some rough corners). Looking at your
nm output, it appears as if the symbols are actually there (at least,
`_ZN7poppler5imageC2Ev` demangles to `poppler::image::image()`, which is one of
the missing symbols.
Your nm output looks like it’s from a .a file though, not a .so. When
resolving symbols in static libraries, GNU linkers only look forwards in the
command line, so if you specify `ld a.a b.a` then undefined symbols in `a.a`
will be resolved to point to `b.a`, but undefined symbols in `b.a` will not be
resolved to point to `a.a`. You can solve this by either providing the
libraries twice (e.g. `ld a.a b.a a.a b.a`), or by using --start-group and
--end-group (e.g. `ld --start-group a.a b.a --end-group`), which searches the
archives in the group exhaustively until it stops resolving all of the symbols.
Or you can use lld, which doesn’t have this braindead behaviour (which is both
user hostile and increases the algorithmic complexity of linking).
I’ve found in the past that GNUstep Make’s interfaces for adding linker flags
leaves a lot to be desired, because it doesn’t give much control over where
things go on the linker command line, but I believe that using the relevant
ADDITIONAL_*_LIBS variable will put the -lpoppler-cpp flag at the end of the
linker command line, which will make it work.
David
On 26 Aug 2017, at 23:03, Jamie Ramone <address@hidden> wrote:
>
> Hello world! I'm trying to build a project of mine in GNUstep which
> requires some functionality provided by an external library, which is
> in C++. I tried to build it with portions in Objc++ but faild. I said
> it couldn't find the symbols it needed (calls to the methods of c++
> objects). So I rewrote the thing moving the c++ dependencies to a
> function in a plain c++ file. Strike 2. I checked around on the web
> and discovered i needed the 'extern "C" {' thingy, so I added that. I
> even rebuilt the external library, knowing that Ubuntu has more bugs
> than rotting wood. Didn't help. I'm all out of ideas. Can anyone help?
> Please let me know what information you need. Thanx!
>
> _______________________________________________
> Gnustep-dev mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/gnustep-dev
Re: linking a C++ lib to an objc tool.,
David Chisnall <=