Kode/Kha

Native Library headerCode file not found

ClintFlames opened this issue · 5 comments

Describe the bug
When compiling project with Native Library getting compilation error:

../Sources/include/hxinc/SMain.h:12:10: fatal error: test.h: No such file or directory
   12 | #include <test.h>
      |          ^~~~~~~~
compilation aborted

To Reproduce
Steps to reproduce the behavior:

  1. F1 > Kha: Init Project
  2. Commands
$ git init
$ git submodule add https://github.com/Kode/Kha
$ cd ./Kha
$ ./get_dlc
$ cd ../Libraries
$ git clone https://github.com/Kha-Samples/NativeLibrary
  1. Renaming NativeLibrary/Sources/Main.hx to SMain (both file and class).
  2. Add line to Main.hx main function
@:privateAccess trace(SMain.nativeAdd(1, 2));
  1. Add line to khafile.js before resolve(project);
project.addLibrary('NativeLibrary')

Expected behavior
Expected trace 3.

Screenshots

Execution Environment:

  • Host system (where you compile your code): Endeavour OS (Arch Linux)
  • Target system (where you run your code): Endeavour OS (Arch Linux)
  • IDE used (if any): VSCode
  • Kha revision: 1cd008c
  • Kha build output (Using Kha...):
    kha_build_output.txt
  • Application output (if it runs): -

Additional context
Also i created repository with steps done https://github.com/ClintFlames/Ancnew

"NativeLibrary" is not a library itself, it is a sample of how to integrate a native library.

Yes, that's understandable. But isn't this a error with the "NativeLibrary" itself. test.h exists, but the compiler says it does not exist. And I just don't understand why.

The reason it doesn't find the file is because the way you do it the C sources are not integrated into the project at all, it only adds the Haxe files. Just because a file exists somewhere on your filesystem doesn't mean a compiler will find it.

"test.h" i was talking about is in NativeLibrary/VeryNative/src. Looks like kincfile.js is reffering to all files in src, so it should detect test.h too, but for some reason it doesn't.

And it does. But as I said before, you are just adding the Haxe files, you do not use kincfile.js. Locking this, all the information you need is here already.