-1

Excuse my ignorance, I need to define something (for example, a function) that can be referenced by another file, without including its code, like this in Lua:

-- main.lua
;print(require './func');

-- func.lua
;return function()
    print 'Hello';
end;

This is possibly duplicate of a question, but I don't find it... When I compile my code, the compiler lets this error in my eyes...

Error in my eyes

Well, my codes are:

//////////////// main.cpp ////////////////

#include "test.h"

int main() {
    test();
    return 0;
}

//////////////// test.h ////////////////

#ifndef INC_TEST
#define INC_TEST

void *test();

#endif  /* INC_TEST */


//////////////// test.cpp ////////////////

#include <iostream>
#include "test.h"

using namespace std;

void *test() {
    cout << "Hello World!" << endl;
}

I compile it like g++ main.cpp -o as3c.exe.

Klaider
  • 3,565
  • 3
  • 23
  • 52

1 Answers1

1

At the moment, your test.cpp is not built, so the linker is not able to find the void* test() function. Specify test.cpp to the compiler to build the code properly. Compile with g++ main.cpp test.cpp -o as3c.exe