not able to run c/cpp execs in eclipse cdt - eclipse

I installed eclipse and then cdt on an ubuntu system recently and was trying to make the first runnable c/c++ proj..
I installed g++ also, and then created the first executable cpp 'Hello World' project
some files are created... then some issues...
even though Build Automatically is selected, I have to goto the
project n do a Build Project to build it manually, and this i have
to do every time I make a change
After Building manually, there are some new folders created with Binaries and Debug files and I can see g++ commands in the console being executed. The project binary is output both to debug n binaries folder. But i am not able to run these through the Green Play Button or any other way in eclipse. Even Run configuration is not showing any option for C/C++ project..
Though I can goto terminal and run the binary myself through ./
But I want to be able to run n debug this through eclipse.
please help in fixing me this problem as I really love eclipse n have some c/cpp assignments coming soon..
Console info on doing a manual project build -
Build of configuration Debug for project qwe **
make all
Building file: ../src/qwe.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/qwe.d" -MT"src/qwe.d" -o "src/qwe.o" "../src/qwe.cpp"
Finished building: ../src/qwe.cpp
Building target: qwe
Invoking: GCC C++ Linker
g++ -o "qwe" ./src/qwe.o
Finished building target: qwe
Build Finished **

I had an identical problem and solved it by installing two additional "C/C++ Development Tools" that didn't show up when I originally filtered for "cdt" in Eclipse software update. Filter for C++ instead and you'll spot them, after install and reboot everything works.

Related

C++ wxWidgets: cross compilation from Raspberry Pi 3

I have a C++ application that uses WxWidgets. It compiles perfectly with g++ on my computer.
However I need to run the application on a Raspberry Pi 3. Compiling directly on Raspi takes almost an hour.
So I want to do a cross compilation: compile it on my computer and copy the executable to raspberry.
I tried to follow a tutorial, however the generated file is an "x86-64" file:
http://yasriady.blogspot.com/2015/10/how-to-build-wxwidgets-for-raspberry-pi.html
My computer:
Ubuntu 20.04.2 LTS;
g++ 9.3.0;
wxWidgets v3.1.5.0;
build flags for my computer: CC_FLAGS=-std=c++17 -w -c -rdynamic -W wx-config --cxxflags --libs --gl-libs geos-config --cflags -lgeos -lglut -lGLU -lGL -lm -lGLEW .
Should I re-install wxWidgets for arm? I'm new to cross-compilation
Thank you so much
I already have wxWidgets installed and compiling for x86. Afterwards, I installed wxWidgets for arm-linux following the tutorial.
When I run "make for the examples from the samples folder, the generated file is for x86.
Maybe "make" is compiling using the x86 compiler, not the newly installed arm compiler.
You should be able to cross-compile for RPi without any problems, double check that you've specified the correct --host option and didn't get any errors from configure (if you did, look at config.log to see why).

No source available in Eclipse

I'm using GDB 7.3 in Eclipse. It's connecting to a GDBServer.
When I launch the debugger in Eclipse I get:
No source available for "main() at 0x101250"
I'm compiling with the optimizer turned off and the debug flag set to max:
-O0 -g3
I see the debug symbols when I run:
./powerpc-unknown-eabi-objdump.exe -g | grep debug
GDB 8.1 is able to find the sources. However, I can't use it due to incompatibilities with the GDBServer I'm connecting to :(
Edit:
I have added the source in the "Source" tab in the "Debug Configuration." I've even added the source manually in the GDB terminal aka "Debugger Console" using the following:
directory /path/to/src/
Source directories searched: /path/to/src/:$cdir:$cwd
For those who have this issue in the future.
The problem comes from using a new version of GCC (GCC 8.1) and an older version of GDB (GDB 7.3)
GCC is putting out a new version of debug symbols that the old version GDB does not know how to deal with. I added flags to GCC to produce older dwarf symbols:
-ggdb -gdwarf-3
Here is the documentation for those flags

Eclipse not finding gcc?

I did a fresh install of my computer, I installed a new Eclipse and imported a program into my workspace. The program was working fine before but now I get this message when I try to compile
Program "gcc -std=gnu99" not found in PATH
I checked if gcc is on my PATH variable and it is
user#computer:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/cuda-5.5/bin
and
user#computer:~$ which gcc
/usr/bin/gcc
Any idea what the problem is?
It appears to be looking for an executable named "gcc -std=gnu99", which of course doesn't exist.
I don't know Eclipse very well, but presumably you have to specify the command name gcc and the argument(s) -std=gnu99 separately.
This question discusses setting gcc options in Eclipse.
From that and my own brief experiments, compiler options are set for each project. After selecting a project, follow this sequence of menus:
Project --> Properties -->C/C++ Build --> Settings --> GCC C compiler
In my installation, I have:
Command: gcc
All options: -O0 -g3 -Wall -c -fmessage-length=0
If you have "-std=gnu99" in the "Command" setting, delete it and add it to the "All options" setting.
This is for Eclipse 3.5.2 running on Debian; the menu hierarchy might be different on yours.
If that's not it, you might also want to check your environment variables:
$ env | grep gnu99

How do I make eclipse acknowledge my include files in a C++ Existing Makefile project?

Simple question: I have a C++ project configured for a existing makefile and it compiles fine. However, the IDE keeps complaining that it cannot resolve most of my symbols.
How do I configure eclipse to use my includes?
Project->properties->C/C++ General->Paths and Symbol
Add the path to your include directory.
You can see in the screenshot, the configuration I use to develop with Qt in C++.
I added my includes in the paths and symbols, but they are not added during qt compilation.
For compilation, qt uses these includes and ignores what I've added:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Idebug -I. -o debug/bp.o bp.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Idebug -I. -o debug/Navigation.o Navigation.cpp
Navigation.cpp:16:22: error: XnOpenNI.h: No such file or directory
Navigation.cpp:17:26: error: XnCppWrapper.h: No such file or directory
Navigation.cpp:18:20: error: XnHash.h: No such file or directory
Navigation.cpp:19:19: error: XnLog.h: No such file or directory
Navigation.cpp:22:16: error: cv.h: No such file or directory
Navigation.cpp:23:18: error: cv.hpp: No such file or directory
I found the answer here:
QT Eclipse Integration - Adding External Libs
It seems that this is a kind of conflict between the CDT and Qt builder, so even if you add the options in CDT as in the screenshot above, the compiler doesn't find them!
You need to add them in the xxx.pro file as this:
http://doc.qt.digia.com/4.5/qmake-variable-reference.html#includepath
I had the same problem when I imported an existing Makefile project with:
File -> New -> Makefile Project with Existing Code
If you don't want to configure anything and just want eclipse to recognize all Paths from your existing (working) Makefile on it's own just do the following:
right click on your project -> Clean Project
right click on your project -> Build Project
The Eclipse Indexer then recognizes all paths on it's own without needing any additional configuration. You just need Eclipse to execute your imported Makefile and everything is resolved (if your Makefile works properly outside Eclipse).
Tested in:
Eclipse IDE for C/C++ Developers
Version: Luna Service Release 2 (4.4.2)
Build id: 20150219-0600

The program can't start because cygwin1.dll is missing... in Eclipse CDT

I've had Eclipse for Java on my computer for a few years, and decided to install the CDT and learn C. I installed both MinGW and Cygwin and the CDT detects and tries to use them when I make a new project.
I choose File > New C++ Project and choose Hello World C++ Project and the CygwinGCC toolchain. I name the project "asdf" and hit "Build Debug" in the toolbar. The compiler completes without error. I hit Run and nothing happens.
Browsing to the project directory manually and running asdf.exe gives me an error saying:
"The program can't start because cygwin1.dll is missing from your computer. Try reinstalling the program to fix this problem."
The same thing happens using MinGW, only a different dll is missing.
What do I need to do to have a usable .exe?
(I'm running Windows 7 x64 and the newest version of Eclipse and the CDT.)
EDIT:
The compiler output is as follows:
**** Build of configuration Debug for project asdf ****
make all
Building file: ../src/asdf.cpp
Invoking: Cygwin C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/asdf.d" -MT"src/asdf.d" -o"src/asdf.o" "../src/asdf.cpp"
cygwin warning:
MS-DOS style path detected: C:\Users\Shawn\Dropbox\eclipse\asdf\Debug
Preferred POSIX equivalent is: /cygdrive/c/Users/Shawn/Dropbox/eclipse/asdf/Debug
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Finished building: ../src/asdf.cpp
Building target: asdf.exe
Invoking: Cygwin C++ Linker
g++ -o"asdf.exe" ./src/asdf.o
Finished building target: asdf.exe
This error message means that Windows isn't able to find "cygwin1.dll". The Programs that the Cygwin gcc create depend on this DLL. The file is part of cygwin , so most likely it's located in C:\cygwin\bin. To fix the problem all you have to do is add C:\cygwin\bin (or the location where cygwin1.dll can be found) to your system path. Alternatively you can copy cygwin1.dll into your Windows directory.
There is a nice tool called DependencyWalker that you can download from http://www.dependencywalker.com . You can use it to check dependencies of executables, so if you inspect your generated program it tells you which dependencies are missing and which are resolved.
You can compile with either Cygwin's g++ or MinGW (via stand-alone or using Cygwin package). However, in order to run it, you need to add the Cygwin1.dll (and others) PATH to the system Windows PATH, before any cygwin style paths.
Thus add: ;C:\cygwin64\bin to the end of your Windows system PATH variable.
Also, to compile for use in CMD or PowerShell, you may need to use:
x86_64-w64-mingw32-g++.exe -static -std=c++11 prog_name.cc -o prog_name.exe
(This invokes the cross-compiler, if installed.)
To add to this and save someone another google, just do this in cmd:
set PATH=%PATH%;C:\cygwin64\bin