Search code examples
c++eclipseconfigurationmingwportable-applications

Portable Eclipse C\C++ Configuration for C++ compiler (without computer installtion (c drive, PATH etc)) on USB


I am trying to program in C++ using Eclipse. However, this requires Eclipse to work on different computers with a MinGW compiler installation everytime. I know that it will work if I install it on a computer and add the location to the PATH variable, but I want to know how to put the compiler onto my USB as well as the Eclipse program and make it work the same way.

It should be installed in such a way that Eclipse can find the compiler on my USB (without the PATH stuff and C drive installation) and compile my program successfully without giving a "Binary not found" error because it could not build my source code.

I've solved this problem with Eclipse Java and am completely able to write and compile Java code. However, I don't know how to do it for a C\C++ Eclipse. Can someone help me with this problem?

Thanks in advance!


Solution

  • You do not need to alter system-wide path variable to help Eclipse finding your compiler. Simply create a batch file, which modifies and exports PATH. For example, put the following in the same directory as eclipse executable:

    set PATH=%PATH%;path-to-mingw-bin
    your-eclipse-executable
    

    Save it as, for example, StartEclipse.bat, and execute it. (of course your-eclipse-executable should be given relative to the working directory of the batch script, and path-to-mingw-bin must be an absolute path)

    You can install your MinGW anywhere, not necessarily in C:\, so installing it shouldn't be a problem.