Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5993687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:42:38+00:00 2026-05-22T23:42:38+00:00

i am trying to call native opengl methods from java. Everything compiles ok but

  • 0

i am trying to call native opengl methods from java. Everything compiles ok but i still get this horrible error in android log cat

ERROR/AndroidRuntime(536): java.lang.UnsatisfiedLinkError:init
                          at com.deo.Glut.Init(Native Method)

according to oracle

UnsatisfiedLinkError is Thrown if the
Java Virtual Machine cannot find an
appropriate native-language definition
of a method declared native

i can’t figure out why the emulator is failing to find my native methods.
//the native methods in glut.cpp (jni/glut.cpp)

#include<jni.h>//compiled using cgwin and ndk-build on windows xp
#include<gles/gl.h>
#include<math.h>

static void gluPerspective(GLfloat fovy, GLfloat aspect,
               GLfloat zNear, GLfloat zFar)//android ndk lacks glu tool kit (unbelievable)
{
    #define PI 3.1415926535897932f
    GLfloat xmin, xmax, ymin, ymax;

    ymax = zNear * (GLfloat)tan(fovy * PI / 360);
    ymin = -ymax;
    xmin = ymin * aspect;
    xmax = ymax * aspect;

    glFrustumx((GLfixed)(xmin * 65536), (GLfixed)(xmax * 65536),
               (GLfixed)(ymin * 65536), (GLfixed)(ymax * 65536),
               (GLfixed)(zNear * 65536), (GLfixed)(zFar * 65536));
    #undef PI
}

JNIEXPORT void JNICALL Java_com_deo_Glut_display
  (JNIEnv *, jobject)
{
glClearColor(1,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);
}

JNIEXPORT void JNICALL Java_com_deo_Glut_reshape
  (JNIEnv *, jobject, jint width, jint height)
{
glViewport(0,0,width,height);
if(height==0)height=1;//prevent a divide by zero error in case it ever tries to occur
glMatrixMode(GL_PROJECTION);
gluPerspective(50,width/height,1,1000);
glMatrixMode(GL_MODELVIEW);
}

JNIEXPORT void JNICALL Java_com_deo_Glut_init
  (JNIEnv *, jobject)
{}

I first declared then tried to call the above methods from java which is causing the error.

package com.deo;
public class Glut//java class that declares my native methods(src\com\deo\Glut.java)
{
    static
    {
       System.loadLibrary("glut");
    }
    public native void display();
    public native void reshape(int width, int height);
    public native void init();//this is somehow generating an error :(
}

then tried to call them from my custom renderer

public Glut myglut;
public   void onSurfaceCreated(GL10 gl, EGLConfig config)
{   myglut= new Glut();
    myglut.init();
}

Please help
download link to project files

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:42:38+00:00Added an answer on May 22, 2026 at 11:42 pm

    Because your file is a cpp file, you will need extern "C" { } around your exported functions. Otherwise the compiler will mangle the function names and Java won’t find the ones it’s looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call the SQL statement below but get the following error: System.Data.SqlClient.SqlException:
I am trying to call native executables from java program. I have three exe
I'm trying to call JDIC from my application, but I can't get it to
I'm trying to get a simple Java method call from C++ while Java calls
I'm trying to call a native function from a managed assembly. I've done this
I'm trying to call a java method from native C code in an Android
I'm trying to call a MBean deployed in JBoss, but i'm having this exception:
I am trying to render an openGL es surface from the NDK, but got
I am trying to call a stored procedure using native query call from an
I'm trying to debug an android app that call native code to do some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.