BeyondProgrammer
BeyondProgrammer

Reputation: 923

Building DLL file in C++ Netbeans

I am trying to build the following in Netbean using c++. However I am unable to do so. I receive the following error.

gcc -shared -m32 -o dist/libJNIDemoCdl.so build/Debug/Cygwin-Windows/JNIDemo.o -mno-cygwin -shared gcc: error: unrecognized command line option ‘-mno-cygwin’

I am only able to build this manually using the following command

gcc -shared -o dist/libJNIDemoCdl.so build/Debug/Cygwin-Windows/JNIDemo.o -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at

How do I fix this issue with the netbean IDE?

Header file

#include <stdint.h>
#include <jni.h>
/* Header for class jnidemojava_Main */

#ifndef _Included_jnidemojava_Main
#define _Included_jnidemojava_Main
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     jnidemojava_Main
 * Method:    nativePrint
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_jnidemojava_Main_nativePrint
  (JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

Source

#include <jni.h>
#include <stdio.h>
#include "JNIDemoJava.h"

JNIEXPORT void JNICALL Java_jnidemojava_Main_nativePrint
        (JNIEnv *env, jobject obj)
{

    printf("\nHello World from C\n");

}

Upvotes: 0

Views: 365

Answers (1)

72DFBF5B A0DF5BE9
72DFBF5B A0DF5BE9

Reputation: 5012

Cygwin and gcc removed the deprecated support of -mno-cygwin flag. It seems you are using and old version of gcc, update your gcc version to GCC >=4.3

Or follow this guide and remove -mno-cygwin flag manually from your builtin toolchain descriptors

Upvotes: 2

Related Questions