简体   繁体   中英

SDL2 compiling for Android with GLEW

This is a compilation problem, specifically with referencing shared libraries with NDK.

I have the SDL2 + GLEW program running fine on my mac (obviously with a different makefile/build system), and I have it running fine on Android as well (so long as I don't use GLEW). But now I need to use GLEW, and can't find a straightforward reference for how/where/what the heck is going on with including libraries in the NDK.

Anyways- in my android-project folder, I have jni/src/Android.mk (which I assume is where I should be looking?)

There's a line with LOCAL_SHARED_LIBRARIES := SDL2 SDL2_image , and I assume that's the magic variable that I shlould add GLEW to? But what even is that? How does that know what GLEW even means? Should it be -lGLEW ? (that last question is rhetorical- I've tried all of them and nothing works). I've even tried commenting out that line totally and get the same build error:

jni/src/src/main.cpp:8:21: fatal error: GL/glew.h: No such file or directory
#include <GL/glew.h>

I'm pretty much totally lost... does anyone have any resources I could look into?

Also, as a note, I'd also prefer an explanation regarding why/what is going on, as I'm sure I'll be including other stuff as I go on.

Edit: As Drop pointed out below, this wasn't a linking problem- the compiler needed to know where to find GL/glew.h . So I added /usr/local/Cellar/glew/1.12.0/include to the LOCAL_C_INCLUDES := line, and that works. But now, there's an error compiling glew.h - GL/glu.h: No such file or directory .

So now,

  1. is there a more general/clean/better way than hardcoding the whole /usr/local/Cellar/glew/1.12.0/include line to let the compiler know where GLEW is? Should glew.h be located somewhere more general?
  2. Why do I only need this when compiling for android? The mac build doesn't need these flags...
  3. I can't find clear documentation anywhere about this, but in compiling the mac build with GLEW, I didn't need to also install GLU and GLUT (like GLEW's website implied...), and further, neither GLU nor GLUT are available as packages via brew .

I've been looking around for documentation about this, but I feel like I don't know what I don't know. Is there some insight you could give to where I'm going wrong regarding how includes and libraries and stuff are expected to be referenced across platforms?

Welp. Turns out there isn't a straightforward way to include GLEW/GLU/GLUT with NDK? (I have a question mark because I'm still not 100% sure...).

However, I found the solution to my problem, and that was- I didn't need GLEW (or GLU, or GLUT, etc...)!

Like I said, I'm building for OSX and android, so I'm using OpenGL 2.1 and OpenGLES2.

I chose to do this because I was told that OpenGLES2 is simply a subset of OpenGL2, so I didn't expect any issues (so long as I didn't use any func's only in OpenGL 2.1).

I needed GLEW because I wanted to use framebuffers ( glGenFramebuffers , etc...), which only exist as an extension in OpenGL 2.1. Once I got that working, I assumed I would need the same extension wrangling for OpenGLES2 on Android- turns out I simply don't! It just kinda works out of the box! (Well, once you get NDK working, and linked with OpenGL, and blah blah blah).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM