c3lang / c3c

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

Build two separate executables in the same project #1419

Closed evanz2608 closed 2 months ago

evanz2608 commented 2 months ago

Is it possible to build two separate executables in the same project? I'm currently testing the language by creating a console game, and I want to make a level editor as a separate program within the same project. I noticed that in the project.json file there is a "targets" object, but adding a second target as an executable results in an error due to the presence of two main functions in separate files. I really like the build system and would prefer not to write a Makefile or create two separate project folders just to resolve this issue.

lerno commented 2 months ago

Place the two mains in separate folders, so for example like this (this is not the only way to do it):

/src-game/main.c3 - contains game /src-editor/main.c3 - contains editor /src/ - contains the common code Then in the game target, add "sources": "src-game" And in the editor target, add "sources": "src-editor"
lerno commented 2 months ago

Did this work well for you? Can I close it?

evanz2608 commented 2 months ago

I did not tried yet because im not at home

evanz2608 commented 2 months ago

I just tried and works fine! You can close it. Thanks!