robovm icon indicating copy to clipboard operation
robovm copied to clipboard

Compiler error for linux console app using gradle plugin

Open dwaal opened this issue 5 years ago • 6 comments

Issue details

I am trying to compile a minimal console app for linux. Here is the content of my robovm.xml

JarV /mnt/Data/tools/JarViewer.jar linux x86_64 console

Reproduction steps/code

The problem (see error at the end) is the missing libraries. The problem is probably that the distribution, layout and content of ROBOVM has changed, so libraries are not found anymore (or maybe not even available since the main focus of ROBOVM is IOS and not Linux console)

If there would be a minimal working example for linux console it would probably solve my issues.

Configuration

Please provide the build system, version(s), and targets affected.

Build Tools:

  • [ ] IDEA plugin
  • [ ] Eclipse plugin
  • [x] Gradle plugin

Versions:

Please provide the version of RoboVM, XCode and JDK used

  • Robovm: 2.3.7
  • XCode: ---
  • JDK: openjdk version "1.8.0_212"

Build Targets: gradle -i -d -S robovmArchive Please provide the build targets this issue is seen on if applicable. e.g. iPhone 4s Simulator 32bit


Stacktrace

//Please provide the stacktrace if applicable 
17:14:05.837 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.apache.commons.exec.ExecuteException: Command 'g++ -o /home/dwaal/Desktop/robovm-gradle-console/build/robovm.tmp/JarV -m64 @/home/dwaal/Desktop/robovm-gradle-console/build/robovm.tmp/objects0 -L /home/dwaal/.m2/repository/com/mobidevelop/robovm/robovm-dist/2.3.7/unpacked/robovm-2.3.7/lib/vm/linux/x86_64 -Wl,-rpath=$ORIGIN -Wl,--gc-sections -Wl,--dynamic-list=/home/dwaal/Desktop/robovm-gradle-console/build/robovm.tmp/exported_symbols -fPIC -lrobovm-bc -Wl,--whole-archive -lrobovm-rt -Wl,--no-whole-archive -lrobovm-core -lgc -lpthread -ldl -lm -lz -lrt' failed (Exit value: 1)
17:14:05.837 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:346)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:149)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.robovm.compiler.util.Executor.exec(Executor.java:344)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.robovm.compiler.util.ToolchainUtil.link(ToolchainUtil.java:404)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.robovm.compiler.target.AbstractTarget.doBuild(AbstractTarget.java:276)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.robovm.compiler.target.ConsoleTarget.doBuild(ConsoleTarget.java:112)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.robovm.compiler.target.AbstractTarget.build(AbstractTarget.java:270)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.robovm.compiler.Linker.link(Linker.java:433)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.robovm.compiler.AppCompiler.compile(AppCompiler.java:514)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.robovm.compiler.AppCompiler.build(AppCompiler.java:953)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.robovm.gradle.tasks.AbstractRoboVMBuildTask.invoke(AbstractRoboVMBuildTask.java:49)
17:14:05.838 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 51 more
17:14:05.839 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
17:14:05.839 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
17:14:05.839 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
17:14:05.839 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
17:14:05.839 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 8s

The real reason is: g++ -o /home/dwaal/Desktop/robovm-gradle-console/build/robovm.tmp/JarV -m64 @/home/dwaal/Desktop/robovm-gradle-console/build/robovm.tmp/objects0 -L /home/dwaal/.m2/repository/com/mobidevelop/robovm/robovm-dist/2.3.7/unpacked/robovm-2.3.7/lib/vm/linux/x86_64 -Wl,-rpath=$ORIGIN -Wl,--gc-sections -Wl,--dynamic-list=/home/dwaal/Desktop/robovm-gradle-console/build/robovm.tmp/exported_symbols -fPIC -lrobovm-bc -Wl,--whole-archive -lrobovm-rt -Wl,--no-whole-archive -lrobovm-core -lgc -lpthread -ldl -lm -lz -lrt /usr/bin/ld: cannot find -lrobovm-bc /usr/bin/ld: cannot find -lrobovm-rt /usr/bin/ld: cannot find -lrobovm-core /usr/bin/ld: cannot find -lgc collect2: error: ld returned 1 exit status

dwaal avatar Jun 15 '19 17:06 dwaal

Maybe this part of ROBOVM is dead code? Just legacy stuff nobody touched for 2 years and it broken now?

dwaal avatar Jun 16 '19 19:06 dwaal

@dwaal mobivm doesn't package rt libs for linux for a while, but you can build them manually and copy to corresponding ~/Users/dkimitsa/.robovm-sdks (and gradle location)

also you will have to build robovmlibllvm as there were changes and nobody rebuild it for linux

dkimitsa avatar Jun 16 '19 20:06 dkimitsa

Thanks for the feedback. Is there any tutorial or guide or wiki entry showing you how to compile all this? I wouldn't even know where to start.

Maybe you should remove the whole Linux-app part from RoboVM...including Gradle tasks, etc.

dwaal avatar Jun 16 '19 20:06 dwaal

there is compiler/vm/build.sh to build VM runtime and compiler/llvm/build.sh to build llvm if required

it should detect linux and just build artifacts for it

dkimitsa avatar Jun 16 '19 20:06 dkimitsa

Resurrecting this issue since I have a reason to want to build linux executables - specifically I would like to be able to build containers to deploy on Google Cloud Run using statically compiled and linked binaries rather than as a JVM app. This will benefit startup times, which is an issue with serverless deployments. Currently this means being able to build console apps for linux-x86_64 targets. In the future linux-aarch64 will probably also be useful.

Progress so far:

A simple console app on MacOs builds and runs. A more complex one fails at link time with this error:

Undefined symbols for architecture x86_64:
  "___darwin_check_fd_set_overflow", referenced from:
      _RAND_poll in librobovm-rt.a(merged.o)

Building a console app on linux fails with missing libraries as per the OP in this issue.

Trying to build the linux libraries on MacOs fails when it gets to some assembler code, probably not unexpected; Building libraries on a linux machine (compiler/vm/build.sh) gets most of the way then fails at this point:

Linking C static library librobovm-core-dbg.a
[ 92%] Built target robovm-core
make: *** [all] Error 2

I will look into this further and see if I can find where it's failing.

clydebarrow avatar Jun 02 '21 07:06 clydebarrow

@clydebarrow hi, was able to build some time ago on pure linux. also I would recommend to play around with build scripts from M1 PR https://github.com/MobiVM/robovm/pull/586 as probably these will replace the one. also would be great to have sample code snippets for failing MacOS console apps. thx!

dkimitsa avatar Jun 02 '21 07:06 dkimitsa