Dan wrote:
I've got a problem with my C++ application that calls a Java class
C++ calling Java is undefined by C++ language, you know. You're in
the are that is not really topical in comp.lang.c++...
that I've built with GCJ,
We here have really no idea what 'GCJ' is, unless you tell us.
I can't run it because I get errors:
multiple definition of `atexit'
first defined here
multiple definition of `_onexit'
first defined here
multiple definition of `__do_sjlj_init'
first defined here
BFD 2.15.91 20040904 assertion fail ../../src/bfd/cofflink.c:2269
illegal symbol index 1091667985 in relocs
ld returned 1 exit status
Multiple definition is usually due to [mis]use of standard libraries,
for example, you link with two of them from different compilers.
D:\Dev\Interceptor\Prototypes\CPP\JavaExperiment\M akefile.win [Build
Error] [JavaExperiment.exe] Error 1
Some background information:
I've written a very simple class in Java with a single method call in
it, I complied this to an object file (.o) using GCJ and then
generated a C++ header file using GCJH.
All that is specific to Java, not to C++.
>
gcj -shared -o NewClass.o NewClass.java
gcjh NewClass
<shrugOK
>
I'm developing the C++ component in Dev C++ so I've added the .o file
as a reference and included the .h file.
Dev C++ is not really topical either. This is a _language_ newsgroup,
sorry.
>
The C++ file is really simple:
#include <cstdlib>
#include <iostream>
I don't believe you're using any part of it.
#include <gcj/cni.h>
That is a non-standard header. Whatever errors come out from using
it cannot be rectified through standard C++ means. You probably need
to contact those from whom you got the header.
#include "NewClass.h"
Whatever that is. The contents of it are unknown, so nothing can be
said about the possibility of errors arising from using it. But you
said it was your own header. Make sure there are no "atexit" defined
in it.
>
using namespace std;
int main(int argc, char *argv[])
If you don't use 'argc', 'argv', there is no need to declare them.
{
system("PAUSE");
return EXIT_SUCCESS;
}
Is there some option I am missing in perhaps GCJ to stop it from
creating the atexit function? It all builds fine when I remove the
reference to my .o file.
Any help would be greatly appreciated...
Not sure what you expect, Dan. The best thing would probably be to
post your Java-specific question in a Java newsgroup. They (Java)
tend to define a lot more (as part of their specification) than C++
does, interaction with C++ is one of those well-defined elements,
IIRC. All I can recommend is to examine what libraries you give to
your linker to see which ones have definitions of 'atexit' (and
the other functions), and then [try to] remove one of them from the
linker command line.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask