How to run makefile projects on clion - c++

If I have a C++ project which uses a makefile to run the code (via the terminal), how can I make a simple to run/debug(!) project in clion? Up to this point I have been using VSCode, but it seems that the Clion interface is much more intuitive (especially coming from pycharm and intellij). But I am having trouble understanding what should I put in the configurations of the project. I am open to changing it to cmake, but I have no idea how to do that too (other than opening a c++ executable new project and copying all contents of my main project).
Really confused here, any help will be appreciated

Related

Codelite not recognizing ns-3 files

I'm pretty new with C++ development, and I wanted to use an IDE. I downloaded codelite, and everything was working fine.
The issue
Recently I started development an App for the NetworkSimulator3 or Ns3, that runs with Waf(https://waf.io/). Using the codelite just for my app, and doing the build&Run on the terminal with waf seems wrong.
In the end, codelite is not recognizing a butch of files of ns3, and keep pointing errors.
What I tried to do
I tried adding all Ns3 files in a single workspace, together with my app files, in hopes that everything would work. Instead I still got a bunch of "No such file or directory" errors, although these files exist and are added on the IDE
On the import, Ns3 demands us to call it like this:
#import <ns3/packet.h>
Although the .h is inside another folder:
src/network/model/packet.h
There are a few wscripts files that probably work on these bindings, although I'm not 100% sure.
So I also tried:
Adding the .h in the same folder of my app
Creating a new virtual folder called ns3, and adding the headers there
Including the folder with the headers in the compiler's include paths
Including the folder with the headers in the linker like it was a library
Nothing worked so far
I just wanted to open the Ns3 on an IDE so I could work without several errors showing. Maybe even with some autocomplete?
Could you guys help me figure this out?
Edit
I also added a "Custom build", so I can execute and build my project using waf, but the IDE errors didn't disappear
On the import, Ns3 demands us to call it like this: #import <ns3/packet.h> Although the .h is inside another folder: src/network/model/packet.h
Headers imported with <ns3/header.h> are copied from src/module/(model/helper) to build/ns3 when you build ns-3. You need to add build/ as an include folder (e.g. -I/path/to/ns-3-dev/build), which will make <ns3/header.h> work correctly.
Not sure on the other issues, since I've never tried CodeLite.
I just wanted to open the Ns3 on an IDE so I could work without several errors showing. Maybe even with some autocomplete?
If I may recommend, try the CMake buildsystem. Clone the code and create a cmake cache folder (e.g. mkdir cmake_cache), then generate the CodeLite project (e.g. cd cmake_cache && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -G "CodeLite - Ninja" .., or -G "CodeLite - Unix Makefiles") and then open the project in cmake_cache with CodeLite. :)
Update: just read on their blog that exporting compile commands is required for code completion when using cmake.
https://codeliteide.blogspot.com/2014/02/codelite-ide-60-cmake-and-clang-code.html

How to create a C++ project in Eclipse CDT using existing source files and an existing CMakeLists.txt?

The title says it all: I have source files and a CMakeLists.txt for an existing C++ project. Now I want to create a project in Eclipse CDT using those files.
I want to be able to build the project with the "build" button from within Eclipse once I'm done, and I want to be able to use GDB.
I've used the CMake option to create Eclipse projects before, but it didn't always work flawlessly and I was told the CMake generator for Eclipse is supposedly outdated.
I know I could just create an empty project and then copy the source files into it, but what about the CMakeLists.txt? I want Eclipse to know how to build the project.
I'm new to Eclipse and there are like fifty ways to start a new project with or without existing source files, so some guidance would be greatly appreciated.

Refactring in CLion isn't working

I have problem with refactoring, e.g. renaming classes in CLion. CLion shows me the refactoring windows, but doesn't find anything to refactor. Screenshots are appended. I also tried to add header files into CMakeLists, but without success. Do you have any idea what I should do?
Thank you.
Edit: I am using Debian 8.2 x64 with Cinnamon
I just added all .h files into CMakeLists.txt into set(SOURCE_FILES ....) and now its work fine.
Thanks to V-R.
If renaming doesn't work, it could be because your project does not successfully build. Try it with a simplest project, e.g. create a completely new Hello World program. I'm sure if it builds successfully, refactoring will work as well. Worked for me in CLion 1.2.4 on OS X 10.9.4.
Concerning CMakeLists.txt, it is a standard file that is created automatically by CLion if you create a new project. If you have an existing project, you will find CMakeLists.txt if you open the menu View->Tool Windows->Project.
My advice is to experiment by closing your existing project (File->Close Project), creating a New Project and playing around with the CLion features. Here is a nice Quick Start Guide for CLion

how to debug source code from Google code repository

I want to debug the following source code from google code repository,
http://code.google.com/p/rx/
My problem is, I am unable to find a suitable ide which can consider all the sub-folders in the source code as one complete project. I have tried netbeans C++, codeblocks, eclipse C++,etc. The problem with all of them while opening the project is that they consider all the subfolders within the main project as different projects.
Is there any ide which can be used for debugging the source code from google code repository. OR IS THERE ANY WAY OF DEBUGGING THESE PROJECTS?
Operating System: Ubuntu or Windows
You can create a dummy makefile :
all:
g++ code_dir/*/*.?pp -o fake
and then import project using Makefiles. This is possible to do for kdevelop and eclipse (not sure for other IDEs).
Take a note that the above makefile imports all files with a *.?pp template from all directories in the code_dir directory.
You can create a new project with your favorite IDE and then import the sources manually.
You might also consider using a decent editor. Personally, I prefer vim and don't see any appealing reason to use an editor 10 times the size of the actual project.

C++ eclipse building error

I'm programming with Galileo on Ubuntu.
My project is compiled through the terminal fine. But for the nice features of eclipse I decided to use eclipse. So I copied and pasted everything inside an eclipse project directory. Then I refreshed the project in the project explorer and everything was found by eclipse. (EDITED) But a red mark (the error mark) is shown on the project icon and when I build the project no binary file is created.
And the last thing is that all the files inside the project have no errors!
what's the problem?
Presumably it is a makefile project. Have you set up the Eclipse IDE to use make with the correct make arguments?
Have you set up the path for the include and lib directories that you need?
Right click on the project in the tree viewer and bring up the preferences dialog and make sure.
There is a console output tab on the Eclipse IDE. What does that say?
There is also a Problems tab that sorts the compiler output. What is on this?
There could well be a problem with building it a a whole project, maybe a link error? More likely it has not been set up properly for eclipse.
Are you using helios? Autotools?