Sublime Forum

C++ Compiling Project with multiple files

#1

I’ve just bought a Macbook Pro Retina 13" Late 2012 and unfortunately my Eclipse (my IDE for C++) scrolling lags and it makes it uncomfortable to develop.

Since I usually work with Sublime Text for PHP and HTML/CSS I’ve decided to give it a try for the C++ language.

I am able to properly build and run a single file project (main.cpp with a simple Hello World), but for the project I was developing (with around 12 separated .cpp and their respective .h) it throws a:

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I can easily compile it through the Terminal by including all the .cpp in the parameters, but I don’t know how to do this through Sublime Text and I would appreciate any help.

0 Likes

#2

This was what I did in sublime 3 but should work for 2 as well.

Go to Tools->Build Systems->New Build System.

Replace the text with:

{
	"cmd": "g++ -g -Wall $file -I. -o $file_base_name"],
	"working_dir": "$file_path",
	"shell": true
}

Obviously change to match whatever you need to build normally.
I don’t know how to make this vary the cmd based on the file you are building :stuck_out_tongue:

0 Likes