remogatto / mandala

A Go framework for writing native Android applications
MIT License
621 stars 50 forks source link

Undefined reference to stderr #9

Closed tbruyelle closed 10 years ago

tbruyelle commented 10 years ago

Not sure if it's related to mandala but when I'm really stuck here. When I execute gotask run android (even with -a flag), I get the following errors :

$ gotask run android
# runtime/cgo
/home/tom/android-ndk-r9d/ndk-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: $WORK/runtime/cgo/_obj/gcc_linux_arm.o: in function _cgo_sys_thread_start:/home/tom/projects/goandroid/go/src/pkg/runtime/cgo/gcc_linux_arm.c:46: error: undefined reference to 'stderr'
/home/tom/android-ndk-r9d/ndk-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: $WORK/runtime/cgo/_obj/gcc_sharedlib_linux.o: in function x_cgo_lib_init_once:/home/tom/projects/goandroid/go/src/pkg/runtime/cgo/gcc_sharedlib_linux.c:109: error: undefined reference to 'stderr'
/home/tom/android-ndk-r9d/ndk-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: $WORK/runtime/cgo/_obj/gcc_sharedlib_linux.o: in function x_cgo_lib_init_done:/home/tom/projects/goandroid/go/src/pkg/runtime/cgo/gcc_sharedlib_linux.c:37: error: undefined reference to 'stderr'
/home/tom/android-ndk-r9d/ndk-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: $WORK/runtime/cgo/_obj/gcc_sharedlib_linux.o: in function x_cgo_lib_init:/home/tom/projects/goandroid/go/src/pkg/runtime/cgo/gcc_sharedlib_linux.c:127: error: undefined reference to 'stderr'
collect2: ld returned 1 exit status
exit status 2

I'm under Ubuntu 14.

remogatto commented 10 years ago

At a first glance, it doesn't seem a problem related to Mandala.

tbruyelle commented 10 years ago

Ok, in that case it's probably related to the ndk toolchain, which doesn't manage to link the std library. But I don't understand why...

remogatto commented 10 years ago

Have you tried to build the goandroid native-activity example?

remogatto commented 10 years ago

Moreover, which version of Go are you using?

tbruyelle commented 10 years ago

Yes I manage to build the goandroid native-activity example. About go version, I have version 1.2 installed in standard and the patched version in the $GOANDROID variable is 1.2.1. Can it be a trouble ?

That said, I think the error is because I installed too many libraries and badly updated some environment variables. So I restarted everything from the beginning (fresh ubuntu install), and the starting error is :

$ gotask run android
# github.com/go-gl/gl
In file included from src/github.com/go-gl/gl/attriblocation.go:7:0:
gl.h:2:21: fatal error: GL/glew.h: No such file or directory
 #include <GL/glew.h>
                     ^
compilation terminated.

So from here I tried to manipulate the C_INCLUDE_PATH and other things (because /usr/include/GL/glew.h exists), which finally leads me to the stderr missing error.

For info I can also build and run the go-gl/examples/glfw3, without errors.

Could please try to build my mandala app ? Maybe it's the simplest thing to do. You can clone it from https://github.com/tbruyelle/mozaik.git.

Thanks in advance.

remogatto commented 10 years ago

It seems you're importing go-gl but in order to run your game on android you need OpenGL ES 2.0 https://github.com/remogatto/opengles2

Please note that you can still use OpenGL on desktop but then you have to

  1. be sure that you're using a subset of OpenGL compatible with OpenGL ES 2.0
  2. compile the android version using the opengles2 package
tbruyelle commented 10 years ago

Ok I see thanks you !

So after some research, it seems I have to rewrite almost all the opengl code in my application. I'm currently using OpenGL 2 and OpenGL ES 2 is based on OpenGL 3 with the usage of shaders... Moreover I'm using a lot methods like glBegin, glEnd, glPushMatrix, glPopMatrix, and those methods doesn't exits in the ES version... Ok fine, see you later ^^.

remogatto commented 10 years ago

Feel free to ping me if you need help.

tbruyelle commented 10 years ago

Thanks a lot I will if needed. The issue can be closed I think.