Sublime Forum

Sublime text 3 C compiler (how can i use functions with header file in main.c)

#1

I want to compile multiple files together located in the same folder (main.c function.c function.h) where function.h is included in main.c like #include “function.h” -in codeblocks it works fine -in sublime text 3 there is a problem that it compiles files individually and pops errors.

can anyone help !

0 Likes

#2

I would open an external terminal (git-bash, cmd, powershell or whatever you like) and do it in the terminal. Write a makefile and “make” it.

ST’s build system is quite naive. It’s good for building a single file but not for a project IMO.

I won’t build/run “project-like” C codes in Sublime Text because

  • The build process (or script name) could vary among projects.
  • If you run your binary in ST and it could not exit normally (infinite-loop, too long to wait or whatever), you would have to kill the background process with task manager by yourself.
  • You could not have standard inputs or it’s quite tricky to have them.

If you have a standard building procedure such as a makefile, it would be easy to build your project in ST.
But, if you want to run your project, you may still encounter problems above with ST’s output panel.

0 Likes