Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.5k stars 168 forks source link

Native Library headerCode file not found #1485

Closed ClintFlames closed 10 months ago

ClintFlames commented 10 months ago

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
  3. Renaming NativeLibrary/Sources/Main.hx to SMain (both file and class).

  4. Add line to Main.hx main function

    @:privateAccess trace(SMain.nativeAdd(1, 2));
  5. Add line to khafile.js before resolve(project);

    project.addLibrary('NativeLibrary')

    Expected behavior Expected trace 3.

Screenshots

Execution Environment:

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

RobDangerous commented 10 months ago

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

ClintFlames commented 10 months ago

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.

RobDangerous commented 10 months ago

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.

ClintFlames commented 10 months ago

"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.

RobDangerous commented 10 months ago

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.