New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when compiling for Android. ' implicit instantiation of undefined template Attribute<int>' #4

Closed
joaqim opened this Issue May 17, 2018 · 17 comments

Comments

Projects
2 participants
@joaqim

joaqim commented May 17, 2018

Having no luck compiling Ui for Android.
Tested with Android-Studio, gradle command-line and CMake cross-compilation. Same error.
Hoping it's a simple thing like missing Header or something stupid on my part that I've missed.

Full CMake output here: https://pastebin.com/RfbuWUuf

`In file included from /opt/android-ndk/sysroot/usr/include/Magnum/GL/Mesh.h:38:
/opt/android-ndk/sysroot/usr/include/Magnum/GL/Attribute.h:84:43: error: implicit instantiation of undefined template 'Magnum::GL::Implementation::Attribute'
VectorCount = Implementation::Attribute::VectorCount

/home/jq/projects/magnum-extras-clean/src/Magnum/Ui/Plane.cpp:53:100 : note: in instantiation of template class 'Magnum::GL::Attribute<3, int>' requested here
Implementation::AbstractQuadShader::ColorIndex{Implementation::AbstractQuadShader::ColorIndex::DataType::Short},

/opt/android-ndk/sysroot/usr/include/Magnum/GL/Attribute.h:41:25: note: template is declared here
template struct Attribute;
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . etc
12 errors generated.
make[2]: *** [src/Magnum/Ui/CMakeFiles/MagnumUi.dir/build.make:179: src/Magnum/Ui/CMakeFiles/MagnumUi.dir/Plane.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:141: src/Magnum/Ui/CMakeFiles/MagnumUi.dir/all] Error 2
make: *** [Makefile:130: all] Error 2`

@mosra

This comment has been minimized.

Owner

mosra commented May 17, 2018

Hi, can you share a few details about what compiler, standard library and magnum version you use? I was successfully deploying the Ui Gallery to Android a month ago, so I think there shouldn't be any serious problem.

@mosra

This comment has been minimized.

Owner

mosra commented May 18, 2018

Thanks for the extensive details 👍

I just tried recompiling everything here (I have android-ndk r16.b though, so Clang 5 ... though I don't expect that the upgrade would break things this much) and experiencing no such errors. Moreover, line 84 in Attribute.h (from your report above) looks different than in current master, are you sure you have a clean working copy of Magnum?

I am on a new dev machine so I have just the NDK installed, no Gradle or anything for building the actual *.apks. Will report back once I have the gallery running on my phone. I'll also try with the new NDK.

@joaqim

This comment has been minimized.

joaqim commented May 18, 2018

Sorry, deleted the extensive comments since I though i solved it by simply removing superflous CMake variable, such as DMAGNUM_INCLUDE_DIR.

I was mistaken and the build failed as before. I will try installing a new clean magnum from git.

@joaqim

This comment has been minimized.

joaqim commented May 18, 2018

Seems the problem might be with my CMAKE_INSTALL_PREFIX,
Might take some time for me to clean up my android-ndk/sysroot and find where everything should be put.

Thanks for the help, will update soon.

@joaqim

This comment has been minimized.

joaqim commented May 18, 2018

No change (still getting the same errors as the first post), feel like I'm back to square one.
I will continue to try to see if maybe it's a faulty include but I'm not optimistic.
The line:84 in Attribute.h was probably changed when I made a naive attempt att forward declaring Attribute etc.

I'm going to see if the error is with my android-ndk platform, reinstalling might take some time.

Is it safe to disregard linker error? Since the compile seems to fail in include/template instantiation stage.

@mosra

This comment has been minimized.

Owner

mosra commented May 18, 2018

huh okay, let me try with latest NDK. You have r17-1, right?

@joaqim

This comment has been minimized.

joaqim commented May 18, 2018

Latest Android-Ndk r17-1

My build script is using:
target=armeabi-v7a
arch=arch-arm
sdk=22

'cmake ..
-DCORRADE_TARGET_ANDROID=ON
-DCMAKE_SYSTEM_NAME=Android
-DCMAKE_SYSTEM_VERSION=${sdk}
-DCMAKE_ANDROID_ARCH_ABI="${target}"
-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang
-DCMAKE_ANDROID_STL_TYPE=c++_static
-DANDROID_STL=c++_static
-DANDROID_NDK=/opt/android-ndk
-DANDROID_NDK_MINOR=${sdk}
-DBUILD_STATIC=ON
-DMAGNUM_INCLUDE_INSTALL_PREFIX=/opt/android-ndk/sysroot/usr
-DCORRADE_INCLUDE_INSTALL_PREFIX=/opt/android-ndk/sysroot/usr
-DCMAKE_INSTALL_PREFIX=/opt/android-ndk/platforms/android-${sdk}/${arch}/usr
-DCMAKE_BUILD_TYPE=Release '

Full script: https://pastebin.com/9UQgbFBL

I started with using the cmake command found PKGBUILD-android-arm64 used in build() and added a lot while trying to make it complie with Ui .

@joaqim

This comment has been minimized.

joaqim commented May 18, 2018

I can't seem to compile magnum with TARGET_DESKTOP_GLES & WITH_WINDOWLESSEGLAPPLICATION.
"missing -lgl".

Will investigate further.

@mosra

This comment has been minimized.

Owner

mosra commented May 18, 2018

Installing latest NDK here.

I started with using the cmake command found PKGBUILD-android-arm64 used in build() and added a lot while trying to make it complie with Ui .

But doesn't the PKGBUILD have everything needed already? It's also enabling the Ui library, just not the gallery, because that one needs to be built with Gradle.

I can't seem to compile magnum with TARGET_DESKTOP_GLES

On Android? Desktop GLES is not available on Android, there's no libGL. This is for OpenGL ES emulation on desktop systems.

@joaqim

This comment has been minimized.

joaqim commented May 18, 2018

You are right, I was just naively trying different options building Magnum.

@mosra

This comment has been minimized.

Owner

mosra commented May 18, 2018

Hmm, installed NDK r17 and still can't reproduce :/ Even tried your script from above, still no luck, the Ui library just builds.

I'm running out of ideas... Can you run make VERBOSE=1 and post the full compiler command-line when compiling Plane.cpp? I suspect there is some global define or something that causes this problem.

@joaqim

This comment has been minimized.

joaqim commented May 18, 2018

make VERBOSE=1 https://pastebin.com/JZHnxHnn

I will clean up my system and try to compile again. But how should I proberly install the PKGBUILDS without conflict? Seems weird to me to only be able to compile for either Android or Unix at any time, maybe I missunderstand how it works.

Going off for a while, will see about it tonight/tomorrow, thanks for all the help, didn't have much luck with google except 'missing header include' which doesn't seem to be the problem.

@mosra

This comment has been minimized.

Owner

mosra commented May 18, 2018

Ahhh. Now it dawned on me. You're compiling for GLES 2.0, right?

At the moment the Ui library doesn't support that (it uses uniform buffers, integer attributes and some more features from ES3). I'll try to backport it at some point, but at the moment it won't work with ES2.

Sorry about the wasted time here. There should have been a big error up-front, not something this deep down in the code.

@joaqim

This comment has been minimized.

joaqim commented May 18, 2018

Ahh will see if I can fix it later, thank you, I was very confused which graphic front-end I was supposed to use at compile. I just used the Platform:: specific stuff for android code and SDL_Context for my own OpenGL drawing on computer.

@mosra

This comment has been minimized.

Owner

mosra commented May 18, 2018

Damn, it should be documented better, sorry. I thought I put it on the Android page, but it's not there :/ Will put more effort into that.

You can use Sdl2Application on desktop and AndroidApplication on Android, as shown here: https://github.com/mosra/magnum-bootstrap/blob/base-android/src/MyApplication.cpp

Some more info is also here.

@joaqim

This comment has been minimized.

joaqim commented May 18, 2018

Thanks for everything, had some time to completely remove my android-ndk directory and re-install everything. It now works flawlessly ^ ^ .
So the error was simply linking Gles2 instead of Gles3 while compiling for Android.
I opened the issue since I was stumped with the type instantiation error. But the error was a simple linker error.

@joaqim joaqim closed this May 18, 2018

@mosra mosra added this to Done in UI May 19, 2018

@mosra mosra added this to the 2018.0c milestone May 19, 2018

@mosra

This comment has been minimized.

Owner

mosra commented May 19, 2018

Just for the record: since 1cd4e56 CMake properly fails with a reasonable error message if one attempts to build it for ES2 or WebGL 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment