When trying to compile a classic error occurs Undefined reference to
Error:(72) undefined reference to 'Cell::num()' Error:(111) undefined reference to 'Cell::Cell(int, int, int)' Error:(175) undefined reference to 'Cell::num()' Error:(49) undefined reference to 'Cell::Cell()' Error:(127) undefined reference to 'Cell::num()' Error:(158) undefined reference to 'Cell::num()' I checked with the textbook, google and so on, I do everything correctly, Cell.cpp
#include <android/log.h> #include "Cell.h" Cell::Cell() { x = 0; y = 0; number = 0; } Cell::Cell(int x, int y, int number) { this->x = x; this->y = y; this->number = number; } void Cell::print() { __android_log_print(ANDROID_LOG_INFO, "out", "(x = %d, y = %d, num = %d)\n", x, y, number); } int Cell::num() { return number; } Cell.h
#ifndef SUDOKU_CELL_H #define SUDOKU_CELL_H class Cell { public: Cell(); Cell(int, int, int); int num(); void print(); private: int number; int x, y; }; #endif //SUDOKU_CELL_H Errors occur in the code when attempting to access an object of the Cell class via array indices
#include <jni.h> #include <string> #include <android/log.h> #include "Cell.h" /** * Generator */ void generate(); /** * Print Helpers */ void printBoard(); extern "C" JNIEXPORT jstring JNICALL Java_iam_thevoid_sudoku_MainActivity_generate( JNIEnv *env, jobject /* this */) { generate(); printBoard(); } Cell board[WIDTH][HEIGHT]; void generate() { ... // Example Cell c(nextX, nextY, number); board[nextY][nextX] = c; int num = board[nextY][nextX].num(); } // // -------------------------- PRINTER ------------------------------------- // void printBoard() { ... ... } For the first time I am trying to start a project with JNI, maybe I am not doing something super obvious, but tips like https://stackoverflow.com/questions/21096819/jni-and-gradle-in-android-studio/21111458#21111458 I'm not bailed out. What can I do wrong?
cell.cfile is forgotten in your project when you buildcell.c. Does he exactly enter the project? Is compiled, linked? - Harry