Aerlusch
Aerlusch

Reputation: 517

What is happening when you set a compilation path?

I understand it is somehow making a connection so that a compiler when envokes connects a source code to whatever libraries that it needs to.

But what is going on a more technical level, or better put what do I need to know in order to confidentally compile code.

I'm working with C++ and MinGW, and have started to look into build files and stuff for Sublime Text 2 (Have learned mostly under unix, or Java + eclipse so far). But what I don't understand what is adding a compiler to your path do for you?

Do I need to add it for every folder I want to compile from? Or is it system wide? I'm really learning this stuff for the first time, we we're never showed how to set up development environments or even deploy code on other systems.

Upvotes: 0

Views: 436

Answers (1)

Leo
Leo

Reputation: 3136

You probably mean include paths and library paths in the compiler:

  • include paths: where the compiler will look for headers; and
  • library paths: where the linker, invoked by the compiler, will look for binary libraries to finish building your project.

If that is the case, look here for a gentle explanation. Basically, what is happening is that the compiler looks in certain places for symbols defined by the operating system and other libraries installed system-wide. In addition to those paths, you need to tell the compiler where to find the symbols defined in your own project.

You may also mean something related to installing the compiler itself or configuring the editor to use it. In that case, what is happening is that you need to tell the build system where to find the executable for the compiler.

Basically, what is probably happening is that your editor wants to know where the compiler is so that it can provide real time feedback on your code. Adding the compiler to the system path will usually, but not always, solve your problem.

In more detail: A C++ build is a rather complex tool chain, involving determining dependencies, preprocessing, compiling, and linking. There are tools that automate that tool chain, and those tools are in turn wrapped into the functionality of modern IDEs like Eclipse, Visual C++, or Sublime Text 2. You many need to tell your editor where to find the tools it uses to provide you with those services.

Upvotes: 1

Related Questions