c3lang / c3c

Compiler for the C3 language
https://c3-lang.org
GNU Lesser General Public License v3.0
3.01k stars 184 forks source link

[ Feature Request ] Linking c obj or lib files in manifest.json #1627

Open tonis2 opened 1 week ago

tonis2 commented 1 week ago

It would be nice to be able to provide some precompiled object files, bundled along in C3l libraries

Its easy to add the -l flag and just link the file, but currently the .o files are not copied into /tmp/ folder, from the c3l file, so the path to the object file will be not working, when including the library. In below manifest.json example the window.o would be copied to /build/tmp by c3 and then auto linked.

{ 
    "provides" : "window",
    "targets" : {
      "macos-x64" : {
        "linked-libraries" : ["Cocoa.framework"],
        "sources" : ["window.c3", "./scripts/window.o"]
      }
    }
  }

Maybe its already possible, but I haven't discovered how to get it working

lerno commented 1 week ago

While this can certainly be added, isn't a static library a better solution?

nmsobri commented 1 week ago

While this can certainly be added, isn't a static library a better solution?

@lerno how can i link to static library using package.json? i cant find it in the documentation

tonis2 commented 1 week ago

I would be happy with static library too, these are the .a files I think ? Basically compile the .o files with ar -rcs libname.a *.o

But yeah, how would it look like to include it to a manifest.json

lerno commented 1 week ago

You would just add it to "linked-libraries", like "linked-libraries": ["somepath/foo.a"]

nmsobri commented 1 week ago

You would just add it to "linked-libraries", like "linked-libraries": ["somepath/foo.a"]

@lerno do you have any documentation for all possible key/val for project.json ?, i mean from the generated project.json i cant see key linked-libraries

tonis2 commented 1 week ago

@nmsobri You can use c3c --list-project-properties on command line, to see project.json properties help

nmsobri commented 1 week ago

@nmsobri You can use c3c --list-project-properties on command line, to see project.json properties help

awesome, this is what im looking for