edgex004
Advanced Member
- Joined
- Jan 5, 2008
- Messages
- 1,222
@Magic Sam , would you mind linking to the solution? I'd like to know the fix as well.
Fatal Error: Mismatch between the program and library build versions detected.
The library used 3.0 (wchar_t,compiler with C++ ABI 1009,wx containers,compatible with 2.6,compatible with 2.8),
and your program used 3.0 (wchar_t,compiler with C++ ABI 1010,wx containers,compatible with 2.6,compatible with 2.8).
/usr/pandora/scripts/pnd_run.sh: line 528: 2126 Aborted
c++ `pkg-config --cflags --libs sdl2 glesv2` main.cpp -o main
#define USE_OPENGLES
#include <SDL.h>
#ifdef USE_OPENGLES
#include <SDL_opengles2.h>
#else
#define GL_GLEXT_PROTOTYPES
#include <SDL_opengl.h>
#include <SDL_opengl_glext.h>
#endif
#include <stdio.h>
SDL_Window *sdl_window;
SDL_GLContext sdl_gl_context;
int main(int argc, char *argv[]) {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "Couldn't init SDL2: %s\n", SDL_GetError());
exit(1);
}
#ifdef USE_OPENGLES
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_CONTEXT_PROFILE_ES);
#endif
#if 0
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
#endif
int video_width = 800;
int video_height = 480;
int window_flags = SDL_WINDOW_OPENGL
| SDL_WINDOW_FULLSCREEN;
sdl_window = SDL_CreateWindow("Test",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
video_width, video_height, window_flags);
if (!sdl_window) {
fprintf(stderr, "Failed to create OpenGL window: %s\n", SDL_GetError());
exit(1);
}
sdl_gl_context = SDL_GL_CreateContext(sdl_window);
if (!sdl_gl_context) {
fprintf(stderr, "Failed to create OpenGL context: %s\n", SDL_GetError());
exit(2);
}
// SDL_GL_MakeCurrent(sdl_window, sdl_gl_context);
// create shader
const char *shader_vert_src = "attribute vec2 va_position; void main() {gl_Position = vec4(va_position, 0.0, 1.0);}";
const char *shader_frag_src = "void main() {gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);}";
GLint is_compiled;
GLuint program = glCreateProgram();
GLuint shader_vert = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(shader_vert, 1, &shader_vert_src, NULL);
glCompileShader(shader_vert);
glGetShaderiv(shader_vert, GL_COMPILE_STATUS, &is_compiled);
printf("compiled %d\n", is_compiled);
glAttachShader(program, shader_vert);
GLuint shader_frag = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(shader_frag, 1, &shader_frag_src, NULL);
glCompileShader(shader_frag);
glGetShaderiv(shader_frag, GL_COMPILE_STATUS, &is_compiled);
printf("compiled %d\n", is_compiled);
glAttachShader(program, shader_frag);
glLinkProgram(program);
glUseProgram(program);
// create vbo
GLuint vbo;
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
float vertex_data[] = {0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f};
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
// setup vertex attribs
GLuint va_position = 0;
glEnableVertexAttribArray(va_position);
glVertexAttribPointer(va_position, 2, GL_FLOAT, GL_FALSE, 0, (GLvoid*)0);
glClearColor(0.4, 0.6, 0.8, 1.0);
for (int i = 0; i < 10; i++) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// draw something
glDrawArrays(GL_TRIANGLES, 0, 3);
SDL_GL_SwapWindow(sdl_window);
SDL_Delay(100);
}
printf("gl error %d\n", glGetError());
SDL_GL_DeleteContext(sdl_gl_context);
SDL_DestroyWindow(sdl_window);
SDL_Quit();
return 0;
}
libGLESv2.so => /mnt/utmp/codeblocks/usr/lib/libGLESv2.so (0x401e2000)
libSDL2-2.0.so.0 => /mnt/utmp/codeblocks/usr/lib/libSDL2-2.0.so.0 (0x4022e000)
libstdc++.so.6 => /mnt/utmp/codeblocks/usr/lib/libstdc++.so.6 (0x40330000)
libm.so.6 => /lib/libm.so.6 (0x400eb000)
libgcc_s.so.1 => /mnt/utmp/codeblocks/usr/lib/libgcc_s.so.1 (0x4008c000)
libpthread.so.0 => /lib/libpthread.so.0 (0x4015e000)
libc.so.6 => /lib/libc.so.6 (0x40429000)
libIMGegl.so => /usr/lib/libIMGegl.so (0x4017d000)
libsrv_um.so => /usr/lib/libsrv_um.so (0x4000c000)
libiconv.so.2 => /mnt/utmp/codeblocks/usr/lib/libiconv.so.2 (0x40550000)
libdl.so.2 => /mnt/utmp/codeblocks/usr/lib/libdl.so.2 (0x4002b000)
libts-1.0.so.0 => /mnt/utmp/codeblocks/usr/lib/libts-1.0.so.0 (0x4006f000)
librt.so.1 => /mnt/utmp/codeblocks/usr/lib/librt.so.1 (0x40191000)
/lib/ld-linux.so.3 (0x400bc000)
X11_GL_LoadLibrary(0x2a040, (null))
LIBGL: Initialising glshim
libGL egl backend: libEGL.so
libGL: built on Oct 22 2015 21:48:58
LIBGL: Current folder is:/home/fabio/devel/gles2_test
X11_GL_LoadLibrary(0x2a040, (null))
compiled 0
compiled 0
gl error 0
SDL_VIDEO_GLES2=1 SDL_VIDEO_GL_DRIVER=libGLESv2.so