Configure Eclipse CDT to use g++ - c++

I have cygwin installed, and I want to use Eclipse with CDT for development under Windows 7. However, I get following error:
**** Build of configuration Default for project hello_cpp ****
make all
g++ -O2 -g -Wall -fmessage-length=0 -c -o hello_cpp.o hello_cpp.cpp
process_begin: CreateProcess(C:\cygwin\bin\g++.exe, g++ -O2 -g -Wall -fmessage-length=0 -c -o hello_cpp.o hello_cpp.cpp, ...) failed.
make (e=5): Access denied.
make: *** [hello_cpp.o] Error 5
**** Build Finished ****
I'm able to use g++ as standalone compiler.
cygwin /bin folder is
added to path.
After googling I found out that C:\cygwin\bin\g++.exe is a cygwin symbolic link and Windows doesn't understand it and I need to point to the g++-3 location directly. How do I do it?

I think you've done something wrong and need to start over again. Just installed Cygwin and Eclipse CDT (Indigo) on my Windows 7 and all works fine and auto-magicaly for me.
Here's what I did and I think you need to do:
Get the latest Cygwin (yes, get it again! get rid of the old one just to be sure)
During the installation make sure to select gcc, gcc-g++ and make (I additionally installed couple of other things like gcc4, w32api but it's optional)
Start Cygwin terminal to init all configuration files, etc. See if g++ executes and close the terminal.
Add C:\cygwin\bin (or wherever else you installed it) to your Environment PATH variable
Get Eclipse CDT, extract it somewhere and start it up.
Go to File -> New Project -> C++ Project and select Hello World C++ Project. You should see the Cygwin GCC in the Toolchains list.
Create the Project, build and run it!
Done!
Build output:
**** Build of configuration Debug for project TestApp ****
make all
Building file: ../src/TestApp.cpp
Invoking: Cygwin C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TestApp.d" -MT"src/TestApp.d" -o "src/TestApp.o" "../src/TestApp.cpp"
Finished building: ../src/TestApp.cpp
Building target: TestApp.exe
Invoking: Cygwin C++ Linker
g++ -o "TestApp.exe" ./src/TestApp.o
Finished building target: TestApp.exe
**** Build Finished ****

You can go to
Project Properties Page > C / C++ Build > Settings > Tool Settings
And change the command as you want. Documentation here.

Refer this link, it shows how to setup eclipse for native development with ease. everything is done in eclipse except setting environment variables.

Related

I am trying to build a single c++ project in Eclipse but getting the build error even if after setting the path variable with mingw path

When click the buildall option in eclipse I am facing below error and object file is not getting created
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\helloworld.o ..\src\helloworld.cpp
Internal Builder: Cannot run program "g++"
Put complete path of c++ compiler present in the mingw, in the enviroment variable of eclipse. Then close the IDE and restart it .

Different GCC version in eclipse, what should I set?

I have installed the latest gcc version, without overwriting the existing one, so now I have two differents gcc versions installed. My question is how do I set eclipse CDT (luna version) to use such version? I've tried by setting in project, properties, C/C++ Build environment and changing the path variable, but it doesn't work.
Specifically the problem I have is:
make all
Building file: ../main.cc
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cc"
g++: error trying to exec 'as': execvp: No such file or directory
make: *** [main.o] Error 1
I changed the path variable to point to the binaries of the the gcc version i've installed.
More Info:
The OS is Red Hat
Please check if you have set the "PATH" in "Environment Variables" correctly
("My Computer -> Properties ->Advanced Settings -> Environment Variables").
Open a cmd prompt and type
echo %PATH%
Verify if the required compiler path is set correctly.
Now restart the Eclipse Luna to get the changes fetched. (Sometimes a system restart is also required)

Problems in setting up GLFW in CodeBlocks

I downloaded GLFW 3.1.1 and followed a tutorial telling me to:
Drop glfw3.h into MinGW's include folder
Drop the contents of lib-mingw in the downloaded file into MinGW's lib folder
Run the test program that comes with GLFW
After doing this I kept running into an error that stopped me from even starting a new GLFW project as the wizard kept looking for glfw.h and glfw.dll when they're now glfw3.h and glf3.dll I edited the wizard and was finally able to get the new project open.
After that, I clicked build and run and the compiler asked if I was sure. When I clicked yes it continually asked me if I wanted to build and run. The debugger just gives me this and I'm not sure what I set up wrong.
-------------- Build: Debug in 112311 (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -g -I"C:\Program Files\MinGW\include" -c "C:\Users\User\Desktop\Folders\C++ Files\112311\main.cpp" -o obj\Debug\main.o
Execution of 'mingw32-g++.exe -Wall -g -I"C:\Program Files\MinGW\include" -c "C:\Users\User\Desktop\Folders\C++ Files\112311\main.cpp" -o obj\Debug\main.o' in 'C:\Users\User\Desktop\Folders\C++ Files\112311' failed.
-------------- Run: Debug in 112311 (compiler: GNU GCC Compiler)---------------
Checking for existence: C:\Users\User\Desktop\Folders\C++ Files\112311\bin\Debug\112311.exe
i
You should avoid using the wizard for GLFW projects because it's for an outdated version of GLFW.
You should create a console application then go to Project->Build Options. Go to the Linker settings tab then add glfw3, opengl32 and gdi32, then click OK.
You can now test if it worked by copying the sample code on the GLFW website's documentation page and pasting it in main.cpp, replacing everything and running the program.

Clang/LLVM on Eclipse (Mac)

I am trying to run Eclipse with the Clang compiler without success. First I went here http://clang.llvm.org/get_started.html and followed the instructions 1 through 8 successfully. I also installed the llvm toolchain via Eclipse marketplace.
What do I do next to successfully compile with Clang? From the installation I have two folders, llvm and build, where do I put them? How do I connect this to Eclipse?
I also downloaded lld in case I needed it since the llvm-ld doesn't work anymore. Below is my error message. I'll be so grateful if someone can help me figure this out! I've wasted a lot of hours on this.
20:09:47 **** Incremental Build of configuration Debug for project recursion ****
Info: Internal Builder is used for build
clang -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o recursiveprint.bc ../recursiveprint.c
lld -v -native -o recursion recursiveprint.bc
Cannot run program "lld": Unknown reason
Error: Program "lld" not found in PATH
PATH=[/usr/bin:/bin:/usr/sbin:/sbin]
20:09:47 Build Finished (took 74ms)

eclipse CDT: rebuilding a dependent project

I'm working on a C++ project with eclipse Indigo + CDT running on linux
It's made of a project for a library, and a project with unit tests for this library.
Obviously the second project depends on the first one.
Both projects use the external builder
But when I modify a header of the first project it does not rebuild the test project. And I can't make it do it... It'll just re-link the second project, even though the header is included in the test project. This is very annoying because I often have working builds while working on the library, then at some point I do a full rebuild and I see a load of errors, on stuff I did 30 minutes ago!
example output of the CDT Global Build Console:
**** Build of configuration Debug for project libxxx ****
make -j all
Building file: ../foo.cpp
Invoking: GCC C++ Compiler
ccache g++ -I"/home/foke/workspaces/cpp/libxxx/include" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"foo.d" -MT"foo.d" -o "foo.o" "../foo.cpp"
Finished building: ../foo.cpp
Building target: libxxx.a
Invoking: GCC Archiver
ar -r "libxxx.a" ./foo.o ./src/yyy.o ./src/detail/zzz.o
ar: creating libxxx.a
Finished building target: libxxx.a
**** Build Finished ****
**** Build of configuration Debug for project libxxx_tests ****
make -k -j all
Building target: libxxx_tests
Invoking: Cross G++ Linker
g++ -L"/home/foke/workspaces/cpp/libxxx/Debug" -o "libxxx_tests" ./main.o ./aaa.o ./tests/bbb.o ./tests/ccc.o ./tests/ddd.o -lboost_unit_test_framework -lxxx
Finished building target: libxxx_tests
**** Build Finished ****
If you're used to the latest versions of MS Visual Studio then you should clear off a space on your desk and mark it with a giant 'X' - this enevitably where your fist and maybe even your head will bang in frustration when using eclipse/CDT.
Eclipse has it's own dependency mechanism which does almost nothing, but fortunately the CDT module has its own dependency mechanism which tries to do what you want. To set up project dependencies go to:
Project-->Properties-->C/C++ General-->Paths and Symbols-->References
So in your example you would go to the project properties for "libxxx_tests" and select "libxxx.a" as a dependency.
Note that you can also use this page to set the library order, which may be an important step depending on the complexity of your project.