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 8669119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:23:32+00:00 2026-06-12T18:23:32+00:00

I am trying to run a simple factorial program written in C++, and link

  • 0

I am trying to run a simple factorial program written in C++, and link it to java UI.

This is my Java code

package com.lan.factorial;

public class FacLib
{

    public native static long fac(long n);
    static 
    {
        System.loadLibrary("FacLib");
    }
    public static long facI(long n)
    {
        return fac(n);
    }
}

`

This is my C++ code

#include <studio.h>
#include <jni.h>
#include "com_lan_factorial_FacLib.h"
JNIEXPORT jlong JNICALL Java_com_lan_factorial_FacLib_fac(JNIEnv *env, jclass, jlong)
{

    jlong f = 1;
    jlong i;
    for(i = 1; i <= n; i++)
    {
         f *= i;
    }
    return f;
}

this is my make file

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SRC_FILES := com_lan_factorial_main.cpp

LOCAL_MODULE := com_lan_factorial_FacLib
include $(BUILD_SHARED_LIBRARY)

and I keep getting this error when I run ndk-build:

C:\Users\Lan\workspace\Factorial>"..\..\temp\android\android-ndk-r8b\ndk-build"
make: *** No rule to make target `jni/com_lan_factorial_main.cpp', needed by `obj/local/armeabi/objs/com_lan_factorial_FacLib/com_lan_factorial_main.o'.  Stop.

Yes, my NDK in a different folder so I have to use ..\..\, but I do not think it is the problem. and I did run javah

  • 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-06-12T18:23:33+00:00Added an answer on June 12, 2026 at 6:23 pm

    As @nneonneo pointed out correctly, the name of your .cpp file name was not correctly listed in Android.mk.

    Now you have a compilation problem in line 4:

    JNIEXPORT jlong JNICALL Java_com_lan_factorial_FacLib_fac(JNIEnv *env, jclass, jlong)
                                                                                        ^
    

    You lost the parameter name n, but you use it in line 9:

        for(i = 1; i <= n; i++)
    

    Note that it’s OK to skip the name of the second parameter of type jclass which you never use.

    I am not sure your compiler found the com_lan_factorial_FacLib.h file, but that’s not a problem: you can remove this #include statement altogether, your code does not use it.

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

Sidebar

Related Questions

I am trying to run the following simple code, public abstract class Shape{ abstract
I am trying to run this dreadfully simple command in Bash java -cp nasa-top-secret.jar
I'm trying to run a simple python program in eclipse. This is the first
I am trying to run a simple java program in linux but getting a
I am trying to run a simple JAVA program once per day on a
I'm trying to run a simple query with PDO in PHP. The code is
I'm trying to run a simple query with $this->db in Kohana, but am running
I am trying to run this simple SELECT query using PDO::MySQL, but it does
I am trying to run a simple password validator. I have already written it
I'm trying to run a simple query with node-mysql like this: client.query(UPDATE mytable SET

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.