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

  • SEARCH
  • Home
  • 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 6978061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:42:25+00:00 2026-05-27T17:42:25+00:00

I have a really weird compilation problem with JNI and don’t know how to

  • 0

I have a really weird compilation problem with JNI and don’t know how to solve it at all…

This is a function which is called from static context in my Java code:

private static final Logger logger
    = LoggerFactory.getLogger(PamHandle.class);

private static native void initLog(final Logger logger);

static {
    System.loadLibrary("pam4j");
    initLog(logger);
}

The header declaring this function is as follows:

#ifndef __LOG__H__
#define __LOG__H__

#include <jni.h>

JNIEXPORT void JNICALL Java_org_eel_kitchen_pam_PamHandle_initLog(JNIEnv *env,
    jclass cls, jobject jlogger);

struct javaLogger {
    jobject logger;
    jmethodID debugID;
    void (*debug)(JNIEnv *env, struct javaLogger *logger, char *msg);
};

extern struct javaLogger logger;

void debug(JNIEnv *env, struct javaLogger *logger, char *msg);

#endif /* __LOG_H__ */

and this is the C file:

#include "log.h"

struct javaLogger logger;

JNIEXPORT void JNICALL Java_org_eel_kitchen_pam_PamHandle_initLog(JNIEnv *env,
    jclass cls, jobject jlogger)
{
    jclass class = (*env)->GetObjectClass(env, jlogger);

    logger.logger = jlogger;
    logger.debugID = (*env)->GetMethodID(env, class, "debug",
        "(Ljava/lang/String;)V");
    logger.debug = debug;
}

void debug(JNIEnv *env, struct javaLogger *logger, char *msg)
{
    jstring jsmg = (*env)->NewStringUTF(env, (const char *)msg);

    if (jmsg)
        (*env)->CallVoidMethod(env, logger->logger, logger->debugID, jmsg);
}

But when I try to compile it (with gcc -c -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -fPIC -g -c -I$JAVA_HOME/include -I$JAVA_HOME/include/linux log.c), this is the output I get:

log.c: In function ‘debug’:
log.c:20:9: error: ‘jmsg’ undeclared (first use in this function)
log.c:20:9: note: each undeclared identifier is reported only once for each function it appears in
cc1: warnings being treated as errors
log.c:18:13: error: unused variable ‘jsmg’

Uh… I am completely flabbergasted. What is going on here? :/ I must be missing something very obvious, I just cannot figure what…

  • 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-27T17:42:26+00:00Added an answer on May 27, 2026 at 5:42 pm

    jmsg and jsmg are two different things.

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

Sidebar

Related Questions

IDE = VS7 or 2002 Hi all, I have a really weird problem here.
This is a really weird problem that I have been having. When I download
This is a really weird problem: I have set up the authlogic_openid_selector_example app .
I have a really weird problem with JS and jQuery. $('#skip').click(function(e) { savePhoto('skip'); showNextPlace();
I have this really weird problem with my MySQL table. After some time a
I have this really weird problem in my code (.Net Framework 3.5). So, in
I have this really weird problem with git on Windows 7. I've installed msysgit,
This is the second time that I have this really weird problem with WCF
We have this really weird problem in a Web Application when using ActiveRecord 2.0
I'm battling a really weird problem here. I have a Windows 2008 R2 server

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.