How to debug external .cpp files on Eclipse CDT ( C++ ) - c++

I have big project in directory "project". I build this project using cmake into another directory "build". For coding I try to use Eclipse, but when I try to import my code into Eclipse ( File->Import->C/C++->Existing Code as Makefile Project ), of course I can import only "build" directory without "project" ( because make file are in "build" and "project" is empty for Eclipse ).
When I run my build in debug mode, I can debug only binary data, because debuger can't seen sources in "project" directory. How I can setup debuger for use sources from "project" directory? Thanks if some one answered!

import your Project (rootdir not build) as MakeFile Project into the Workspace (select GNU Toolschain or Linux GCC). Now open your project properties -> c++ build and select the build folder inside your project.
Now you can compile it and create a new run configuration for debugging.
Greez ZuSe
Edit:
I assume your rootfolder looks like this
cmake/
CmakeList.txt
src/
dep/
../
now you create a folder build
you switch to build and run cmake cmake ../ -flags (no eclipse-project, use default gcc)
After you have done this u can import your rootfolder to eclipse cdt and select root/build as build folder. Where is the problem? Eclipse CDT only wants to now where the makefile is at buildtime (thats why you manually need to select the buildfolder)

You do not need sources in your workspace to debug the application if you built the application on your system - build directory & paths are in your executable debug information.
Make sure you pass -g both to the compiler and linker.
Try command-line GDB - it should find sources as well.
You may setup custom source mapping in the Eclipse CDT debugger when setting up the launch configuration - but I believe this is mostly for cases when sources were moved after you built the application or if you built on another system.

Here is how i do it, step by step. It is a simple cmake project i downloaded from github.
Works like a harm.
imagebam.com http://thumbnails101.imagebam.com/23645/1e5c42236445850.jpg
imagebam.com http://thumbnails101.imagebam.com/23645/64cb47236445860.jpg

Related

Specifically use make instead of ninja when importing cmake project in KDevelop

I am trying to set up a c++ project I am working on in KDevelop, since it looked like an interesting IDE. For this project I am using cmake and make, but for some reason when I import the project using the CMakeLists.txt file it is setting up the KDevelop project to use ninja. I haven't been able to find any way to switch the project to using make, either online or just by digging through the menus. Is there any way to do this?
The relevant setting is Settings -> Configure KDevelop -> CMake -> Default generator.
If the build directory is already configured with -G"Unix Makefiles" (or another generator) when you import the project, KDevelop should detect and use that backend regardless of the default.

How can I build a project with CMake?

I've downloaded a source of leptonica-1.74.4
I need lib, dll and *.h files for using with tesseract lib.
As I understood firstly I have to build this source with CMake and then I'll get VS files. (Or maybe lib and dll???)
I've never work with CMake. Have no idea how to run CMakeLists or whatever through CMake. What should I do?
I was trying to read documentation and it just made me confused.
OS Windows 8.
CMake ist not a build system but manages the build process within your native build environment - in your case (Win8 + VS) it'll create the project and solution files you can use in VisualStudio.
For your specific case it will be best to
Download, install and run CMake-GUI
Specify the source folder(where CMakeLists.txt is located)
Specify the build folder(where the libs / executables shall be build)
Press "Configure" - you will be asked for the generator you want to use - ideally you choose the VS version you have installed in your system.
Press "Generate" - cmake generates the .vcxproj and .sln files in your build folder corresponding to the VS version you have chosen.
Open the .sln file and start building leptonica or integrate the project into your own solution.
In addition - CMake allows you to directly trigger the build with your native compiler. But this needs to be done via the console.
more information here

Eclipse doesn't see include files when checking syntax but does when building or running the application

I started with building my project with CMake by using the cmake <folder> -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug command (I'm using Ubuntu 14.04). Say the results were written to /home/student/tempFolder/HelloFrameworkApp folder.
The thing is that I have header files needed for he application in /home/student/git/fagot/sw/branches/head/framework/include folder. This is also described in CMakeLists so after I import my project from /home/student/tempFolder/HelloFrameworkApp to Eclipse as existing code as makefile project, it can successfully be built and runs just as expected.
But in the code edit area there are tons of red underlining which makes it clear that Eclipse can't see the include folder I mentioned before. I tried going to Properties -> C/C++ General -> Paths and symbols and adding that include folder to all configurations and languages but it didn't help.
Any suggestions?
CMake creates an Eclipse project for you. Therefore you need to use: Import->General->Existing Project into Workspace.

How to set Eclipse for cmake project?

I have c++ project with cmake, for building it,i wanted to integrate the project in eclipse ide in linux?And i also googled for the same,but didn't get appropriate answers,Please help me with the same.Thank you in advance.Other IDE are also ok,with steps to import the project without ant errors.Thanks for the help in advance.
The cmake4eclipse Eclipse plugin from the Eclipse marketplace is able to create makefiles (or other buildscripts; it is your choice) from your CMakeLists.txt and build your Eclipse project. Once configured, there is no need to manually run cmake -G "Unix Makefiles". Project settings are stored in the .cproject file and taken from your CMakeLists.txt.
It integrates to CDT, so using the plugin, You should be familar with CDT`s project preference pages (which may be confusing).
To have syntax highlighting in CMakeLists.txt, try cmake-editor.
DISCLAIMER: I am the author of cmake4eclipse.
Using CMake you can generate a project for Eclipse and then open it in the IDE. CMake will be called automatically to regenerate project if you make some changes at that level.

How to setup a makefile in eclipse (C++)?

I have a project in Eclipse and I want to use my own makefile.
I went to
project -> properties -> C/C++ Build
and unchecked "Generate Makfiles Automatically". I have a makefile named Makefile in the project base dir which just contains:
all:
g++ *.cpp -o Simulator.exe
When I try to build, I get the following error:
Build of configuration MinGW GCC for project CacheOptimization
(Cannot run program "make": Launching failed)
How can I fix this and make eclipse compile my code?
You probably don't have MINGW configured properly, and Eclipse can't run "make". This might be useful: Setting up a compiler
Either:
install MSys package which includes make along with other useful tools (recommended),
or look into your project's settings under C/C++ Build and change the build command from make to mingw32-make, which is distributed as a part of MinGW.