public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* GtkSpell Link Error
@ 2008-08-21 13:51 PEACEYALL
  2008-08-21 14:06 ` John Love-Jensen
  0 siblings, 1 reply; 5+ messages in thread
From: PEACEYALL @ 2008-08-21 13:51 UTC (permalink / raw)
  To: gcc-help

Hello,

I am trying to dynamically link the gtkspell library which is coded in
C with my program which is coded in C++. Merely when I try to compile
it, g++ outputs the following error:
/tmp/ccDGjLyg.o: In function `ConvoWin::appendPage(Gtk::TreeIter&)':
ConvoWin.cpp:(.text+0x67e8): undefined reference to
`gtkspell_new_attach(_GtkTextView*, char const*, _GError**)'
collect2: ld returned 1 exit status

The example programs that came along with the library compiled, linked
and worked perfectly fine.
I even coded a small test program in C and it compiled and linked with
gcc to the gtkspell library perfect fine too.
Although, if I try to compile the test program with g++ with the "-x
c" argument, it compiles and links properly, but when I try to compile
it with the "-x c++" argument, it too results in the error above.

Why is it that linking the gtkspell library to C code works while
linking it to C++ code results in the error mentioned above?
Likewise, is there any fix for this issue that will allow me to link
the gtkspell library into my C++ code?

Any amendments or suggestions will be kindly appreciated. Thank you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GtkSpell Link Error
  2008-08-21 13:51 GtkSpell Link Error PEACEYALL
@ 2008-08-21 14:06 ` John Love-Jensen
  2008-08-21 14:18   ` PEACEYALL
  2008-08-21 15:07   ` John Love-Jensen
  0 siblings, 2 replies; 5+ messages in thread
From: John Love-Jensen @ 2008-08-21 14:06 UTC (permalink / raw)
  To: PEACEYALL, GCC-help

Hi PEACEYALL,

Is gtkspell C++ savvy?

You should see something like this in the gtkspell header files if they are
C++ savvy:

----------------------------------------------------------------------
#ifdef HEADERGUARD
#define HEADERGUARD

#include "blah.h" // headers that gtkspell's header depends on

#ifdef __cplusplus
extern "C" {
#endif

//...the meat of the header...

#ifdef __cplusplus
}
#endif

#endif // HEADERGUARD
----------------------------------------------------------------------

If the gtkspell headers are NOT C++ savvy, you'll should instrument them
by-hand with the __cplusplus bits above.

Alternatively (but not recommended by me), you might try to attempt a proxy
header:

my_gtkspell.hpp
----------------------------------------------------------------------
extern "C" {
#include "gtkspell.h"
}
----------------------------------------------------------------------

The reason I do not recommend this approach is because the extern "C" is
also (perhaps incorrectly) applied to any #include headers that gtkspell.h
itself includes, and those headers may get befuddled and you end up in a
much worse mess.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GtkSpell Link Error
  2008-08-21 14:06 ` John Love-Jensen
@ 2008-08-21 14:18   ` PEACEYALL
  2008-08-21 15:09     ` John Love-Jensen
  2008-08-21 15:07   ` John Love-Jensen
  1 sibling, 1 reply; 5+ messages in thread
From: PEACEYALL @ 2008-08-21 14:18 UTC (permalink / raw)
  To: John Love-Jensen; +Cc: GCC-help

On Thu, Aug 21, 2008 at 5:50 PM, John Love-Jensen <eljay@adobe.com> wrote:
> Hi PEACEYALL,
>
> Is gtkspell C++ savvy?
>
> You should see something like this in the gtkspell header files if they are
> C++ savvy:
>
> ----------------------------------------------------------------------
> #ifdef HEADERGUARD
> #define HEADERGUARD
>
> #include "blah.h" // headers that gtkspell's header depends on
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> //...the meat of the header...
>
> #ifdef __cplusplus
> }
> #endif
>
> #endif // HEADERGUARD
> ----------------------------------------------------------------------
>
> If the gtkspell headers are NOT C++ savvy, you'll should instrument them
> by-hand with the __cplusplus bits above.
>
> Alternatively (but not recommended by me), you might try to attempt a proxy
> header:
>
> my_gtkspell.hpp
> ----------------------------------------------------------------------
> extern "C" {
> #include "gtkspell.h"
> }
> ----------------------------------------------------------------------
>
> The reason I do not recommend this approach is because the extern "C" is
> also (perhaps incorrectly) applied to any #include headers that gtkspell.h
> itself includes, and those headers may get befuddled and you end up in a
> much worse mess.
>
> HTH,
> --Eljay
>
>

Hello again,

Thank you for your reply Eljay.

I have tried both approaches and they both seem to fix the issue
without any other issues arising.

Though, which one do you recommend, since I do not wish to
redistribute the fixed gtkspell library with my program. Which would
be the better approach?

Thank you again for your help.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GtkSpell Link Error
  2008-08-21 14:06 ` John Love-Jensen
  2008-08-21 14:18   ` PEACEYALL
@ 2008-08-21 15:07   ` John Love-Jensen
  1 sibling, 0 replies; 5+ messages in thread
From: John Love-Jensen @ 2008-08-21 15:07 UTC (permalink / raw)
  To: John Love-Jensen, PEACEYALL, GCC-help

Oops... (lol)... that should have been...

> #ifndef HEADERGUARD

Disclaimer: the code in the previous post was written off the cuff, and has
not been compiled or tested.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GtkSpell Link Error
  2008-08-21 14:18   ` PEACEYALL
@ 2008-08-21 15:09     ` John Love-Jensen
  0 siblings, 0 replies; 5+ messages in thread
From: John Love-Jensen @ 2008-08-21 15:09 UTC (permalink / raw)
  To: PEACEYALL; +Cc: GCC-help

Hi PEACEYALL,

> Though, which one do you recommend, since I do not wish to
> redistribute the fixed gtkspell library with my program. Which would
> be the better approach?

I think that instrumenting gtkspell's headers so that they are C++ savvy is
the better approach.

I do not know what burden that puts upon you for gtkspell (re)distribution,
or gtkspell's licensing, or if such modifications are allowed, or whatnot.

> Thank you again for your help.

You're welcome.  :-)

Sincerely,
--Eljay

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-08-21 15:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-21 13:51 GtkSpell Link Error PEACEYALL
2008-08-21 14:06 ` John Love-Jensen
2008-08-21 14:18   ` PEACEYALL
2008-08-21 15:09     ` John Love-Jensen
2008-08-21 15:07   ` John Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).