Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with using GCC/CMunge for modules with C++

4 views
Skip to first unread message

Terje Slettebø

unread,
Aug 27, 2011, 1:03:52 PM8/27/11
to
Hi.

I've read through the documentation, but still haven't found the
answer, so I'm trying my luck here:

I've installed GCC, and when testing for example the "Simple" module
in the Examples.Module directory, it compiles and runs just fine.

I've then modified the makefile slightly to use g++ instead of gcc,
and saved gccmodule in a "cc" directory, and added code to call a
couple of overloaded functions from gccmodule_init() (to test if it's
really compiled as C++), printing some text, which still works.

However, if I try to use any of the C++ standard library there, I run
into problems... For example, adding this code to the top of
gccmodule.cc:

#include <vector>

std::vector<int> v;

gives this error:

gccmodule.o: In function
'__static_initialization_and_destruction_0(int, int):
gccmodule.cc:(.text+0xd8): undefined reference to 'operator
delete(void*)'
collect2: ld returned 1 exit status

Has anyone been able to use the C++ standard library in GCC modules?

If so, then I'd appreciate either a working example, or some pointer
to how I might fix this problem...

Regards,

Terje

Rick Murray

unread,
Aug 27, 2011, 2:58:21 PM8/27/11
to
On 27/08/2011 19:03, Terje Slettebř wrote:

> Has anyone been able to use the C++ standard library in GCC modules?

Thinking back to ANSILib [*]; if it is a standalone bit of library code
that links to the executable (as opposed to SharedCLib), perhaps you
need a version compiled as module code?


Best wishes,

Rick.

* - There only seems to be one ANSILib in the later tools, but this was
from back in the days when CLib wasn't a standard module. I'm pretty
sure there were "standard" and "module" versions of it.

Terje Slettebø

unread,
Aug 27, 2011, 3:26:04 PM8/27/11
to
On Aug 27, 8:58 pm, Rick Murray <heyrickmail-use...@yahoo.co.uk>
wrote:

Hi Rick.

Good to see you around, I enjoy your writing. :)

By the way, you might be interested to know that this is related to
this thread: http://www.riscosopen.org/forum/forums/5/topics/731

Looking at the error message again, and considering the code used
(gccmodule_initt() is defined as "extern "C" ", or it won't link with
the CMunge object file), it could be that the compiler tries to
resolve a reference to a C-linkage "operator delete()", when it's
obviously a C++ function...

I _have_ tried calling C++ linkage functions from gccmodule_init(),
that were defined in the same source file (outside the "extern" area),
and that worked, but still, this might be linkage/lookup related...

What you say could be the case, but I have no idea how I would get a
"module" version of the GCC standard library...

I'm still hoping that someone else have succeeded in this, and is
reading this... John Tygat is credited for work on CMunge related to
using it for GCC, so he might have an idea, but I don't have his mail
address.

Thanks, :)

Terje

Terje Slettebø

unread,
Aug 28, 2011, 12:30:42 PM8/28/11
to
With help from the GCC SDK mailing list, I got this to work, by using
"g++" (rather than "gcc") also in the LINK part of the makefile. :)

It still crashes at runtime if I use std::cout, there (rather than C
output functions), but the important part is that the C++ standard
library is now available.

Regards,

Terje

0 new messages