GCJ Duplicate a dummy character

I am trying to create a Java application with gcj but I get the error below. It has been a while since I used gcj (a year or so), so I may have forgotten something not obvious, but I'm sure I always did it.

multiple definition of `java resource .dummy' 

gcj version 4.4.1 on Ubuntu and 4.3.4 on cygwin / windows XP, and I create it using

  gcj --main=my.MainClass --classpath=my my/*java 

Has anyone seen this or know a workaround without installing an earlier version of gcj. If this is the way to do this, does anyone know how to do this on cygwin or do I need to build it?

Here is a minimal test case that gives this error

 public class A { public static void main(String[] args) { System.out.println(new B()); } } public class B { public String toString() { return "Hello"; } } gcj --main=A src/A.java src/B.java 
+4
source share
4 answers

From this 42143 and 43302

The only solution reported is compiling the class files, and then a link to the class files.

The following errors are not thrown:

 gcj -I src -C src/A.java src/B.java gcj -I src --main=A src/A.class src/B/class 
+5
source

If you create by compiling .java files into .o files using gcj -c , you can also fix this problem by making dummy characters local with objcopy:

 objcopy -L '_ZGr8_$_dummy' Ao 

This works well with the Makefile - just add the %.o: %.java rule:

 objcopy -L '_ZGr8_$$_dummy' $@ 
+3
source

At least with some version of gcj, by explicitly specifying the output executable using -o, it will make it work:

gcj --main = my.MainClass -o myexe --classpath = my my / * java

I have no explanation for this behavior.

+2
source

Not a solution to the mentioned problem, but a way to compile your own code: 1. compile the jar archive using sun / openjdk 2. convert the jar to an executable file using

 gcj project.jar --main=package.name.ClassWithMainMethod 
+1
source

Source: https://habr.com/ru/post/1305854/


All Articles