Search code examples
ceclipsegccgdbwindows-subsystem-for-linux

Eclipse C/C++ project on Bash on Ubuntu on Windows


I've installed Eclipse Neon (v4.6). Also, I have "Bash on Ubuntu on Windows" (Sept '16). I installed gcc and gdb for compiling and debugging in C. I tested them on terminal and they're running.

I'm trying to use Eclipse to create a new C project but in the compiler selection stage it doesnt give me the option to use the "Bash on Ubuntu on Windows" compiler.

Is there any way to solve my problem?


Solution

  • We use Eclipse and a makefile project. I configured Eclipse by adding an "external builder" - and use the following script:

    -c "cd `echo '${project_loc}' | sed  -e 's/C:/\/mnt\/c/g' -e 's/\\\\/\//g'` && make -f path_to_makefile/makefile
    

    The "cd" and sed trick is to convert from Eclipse "C:\" to Windows Subsystem for Linux "/mnt/c/" and replace "\" with "/"

    Make now executes in the project location as defined by ${project_loc}

    I still have not figured out how to execute gdb on Linux. But at least compile+link (and execute unit tests as defined in my makefile) is now leveraging the full speed of the native Ubuntu toolchain...