#Using build.zig for a C++ project

1 messages · Page 1 of 1 (latest)

vale glen
#
  1. Does each addCSourceFile() call create its own obj?
  2. If it doesn't, can you create separate addStaticLibrary()s and use their result in the final step?
  3. If either of those work, do they run in parallel with each other?
jolly kernel
#

A static library is an archive of one object per compilation unit, so in C that's one per C source file.

vale glen
#

Confused as you can have multiple C files compile to a single object file by having them in the same compilation unit

#

i.e. clang a.c b.c -o ab.o

hazy jetty
#

That's not doing what you think it is: clang by default is going to try and make an executable, not an object. To tell it to generate object files you have to pass -c, but then you'll get error: cannot specify -o when generating multiple output files. One compilation unit is precisely the same as one C file, and as such there's always a 1:1 correspondence between input C files and object files

vale glen
#

ah ok, so addCSourceFiles() already handles separate obj generation?