How to load and index C++ project to CLion without dependency - clion

I have big C++ project, with many dependences. I don't want to build it on my local PC, just edit, so i really don't want to install all dependences. But in this way, CLion doesn't index project, and i can't use: Find Usages and Go To -> Declaration\Definition\.... Is it possible to load and index C++ project in CLion without dependences?

Related

Avoid Modifying Compiler and Linker Settings every time to use SDL in projects

I have recently started with my plan to develop a simple game and for that, I have installed SDL for VS. But Every time I create a new project I have to go to properties-> Compiler and properties-> Linker of that project to add my SDL libraries. Can I permanently include these settings.
Also, does it necessary to include ".dll" every time in my project or I can link them too for anytime usage.
I have been using CMake with VS and SDL lately and it reduces this annoyance a bit. Your top directory (and additional directories, depending on how you organize your project) will have a CMakeLists.txt file which handles include directories, finding libraries and DLLs, and building any dependencies. The one for my current project looks like this:
cmake_minimum_required(VERSION 3.19)
project(chip8emu VERSION 1.0 DESCRIPTION "Chip-8 Emulator" LANGUAGES CXX)
set(SDL2_INCLUDE_DIR "C:/dev/vclibs/SDL2-2.0.14/include")
set(SDL2_LIBRARY "C:/dev/vclibs/SDL2-2.0.14/lib/x64")
FIND_PACKAGE(Boost REQUIRED COMPONENTS log)
FIND_PACKAGE(wxWidgets)
ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
add_executable(chip8emu chip8emu.cpp chip8.cpp chip8.h "logger.h" "logger.cpp" "emuWindow.h" "emuWindow.cpp" "beeper.h" "beeper.cpp" "cApp.h" "cApp.cpp" "cMain.h" "cMain.cpp" )
target_link_libraries(chip8emu PRIVATE Boost::log_setup Boost::log ${SDL2_LIBRARY}/SDL2main.lib ${SDL2_LIBRARY}/SDL2.lib ${wxWidgets_LIB_DIR})
I can basically copy and paste this into each project directory (changing the add_executable() line).
There are positives and negatives to this approach, but I like it because it makes it easy to integrate libraries and it makes me less dependent on VS. This is a good tutorial to start with (although it looks intimidating, its pretty simple).

How to compile projects in Xcode with make files

I have a question , if I have a makefile with which help I can compile my source code in terminal , but how can I do the same with Xcode , and does Xcode need makefiles always when we compiling project ? I actually don't understand how linker works with makefiles , why it works perfectly with the small projects and why ( if not ) I can't either compile a huge project without makefiles.
Im new in makefiles...
Create an external build system project to use makefiles in Xcode. Most of Xcode's project templates are designed to use Xcode's build system, not makefiles.
You can find the external build system project template in the Cross-Platform section of the New Project Assistant.
When you click the Next button, you will notice the project is already set to use make as the build tool.

Eclipse CDT, how to make it NOT search for system headers?

I'm porting a C project compiled on linux to an arm platform using Eclipse Luna on Ubuntu 16.04
When I switch from CC=gcc to CC=arm-none-eabi in the Makefile I get a lot of missing headers and that's ok, that's what the porting job is about.
What bothers me is that when I CTRL-click on a symbol Eclipse doesn't open the corresponding file for the arm toolchain. For instance if I CTRL-click on <time.h> it does NOT open:
/media/BUILDS/arm_gcc493/arm-none-eabi/include/time.h
but instead it always reverts to its linux system counterpart, in this case
/usr/include/i386-linux-gnu/time.h
because that's where gcc would look for but I'm compiling with arm-none-eabi-gcc instead!
I don't want Eclipse to do that because debugging gets really confusing. If I have a problem with the header/source I'm actually trying to compile with, I want Eclipse to open me that file and not the default system one. I fiddled with Project Properties and Eclipse Preferences but with no luck.
Even worse, whenever <sys/socket.h> is included I get an error because the arm toolchain does not have socket.h but if I CTRL-click on it Eclipse takes me to /usr/include/i386-linux-gnu/sys/socket.h
I dont' want that, if the header needed for compilation is not there, it's just not there. I don't want Eclipse to show me other stuff, how do I do that?
The project was created importing into the workspace "Existing Code as Makefile Project" under C/C++
Thank you very much
EDIT:
I did the proper thing and started from scratch creating a project for the Cross ARM GCC Toolchain (with the proper plug-in). My mistake was creating a "Linux GCC" Project and pretending that Eclipse understood what I was trying to achieve just by launching a different "make" command. If, however, you can't restart from scratch, the accepted solution instructs you on how to fix the situation manually.
To resolve this situation you need to update the Preprocessor Include Paths, Macros, etc. setting to use your custom-prefix GCC.
To make the change:
Open Project Properties (Right-click on project and choose Properties)
In C/C++ General -> Preprocessor Include Paths, Macros, etc., choose Providers tab
Select CDT GCC Built-in Compiler Settings
Uncheck Use global provider shared between projects
Replace ${COMMAND} with arm-none-eabi-gcc or arm-none-eabi-g++
Alternatively, you can also edit the same setting at the workspace level to affect all the projects in your workspace. Go to Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery tab instead.
Here are some screenshots that may help.
Before:
Project Properties:
After:

Qt Creator: Projects that use other projects as libraries

I've written a small library as a Qt project using Qt Creator, now I want to create a small GUI application that can be used to test it as part of the development process, so it could be like this:
Project root at:
~/code/mylib
Library project and associated code:
~/code/mylib/corelib/corelib.pro
GUI test tool and associated code:
~/code/mylib/libgui/guitool.pro
So far I've only been able to make things work by setting up LIBS+= in the GUI project's .pro file, manually building the library, copying the library's .a file to the GUI directory, and rebuilding the GUI project. A tedious process. Worse: I'm developing the project now on Linux but need to make it build on Linux and Windows, and this manual build style will probably make that harder.
I suppose there's a way to do make Qt Creator aware of the relationships between the projects, so for example building the GUI tool in debug mode use the debug version of the library, or making changes to the corelib would necessitate a build in the GUI, building on some OS would use the libraries OS-configuration...etc
This kind of thing is a couple of clicks away in Eclipse and Visual Studio, but I can't seem to get it working in QtCreator. I've tried "Add library->Internal library" and creating a 'subdirs' project but neither seems to work. I feel it's probably a simple step that I'm missing somewhere, any help?
Try again to use subdirs feature. It have own wizard "Project with subdirectories", but in your case it's easier to write it manually (in example I've added "ordered" to ensure that order of compilation is always correct).
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = corelib guitool
Than you can add libary to your GUI application with wizard (accessible from context menu inside .pro).

Using Xcode for generic C/C++ development

I'd like to use all the power of Xcode for generic C/C++ projects but I can't figure out what are the basic steps to configure a new Xcode project and attach it to an existing source tree of a legacy, plain, C/C++ project.
Creating a new empty project, attaching it to a source tree and configuring a build target (using GNU Make) was a really silly task.
I can't figure out how to enable source code indexing in order to enable source refactoring tools, searching and fast-jumping and all the amenities that makes the Xcode programmer's life great.
Moreover I'd like to use the internal debugging facilities…
Does anyone point me to a tutorial, a hint or whatever could be useful?
Thanx
I've found a (dirty) path to enable refactoring tools:
I've added a new standard «console target» to the project and added all the source files under the Build Phases > Compiled Sources.
Refactoring tools now works. Having two targets doesn't seem to be a relevant issue (elegance apart)
Personally, I wouldn't attempt to use legacy Makefiles, even though I think there's some support for that.
Typically what I do with a traditional C/C++ project is to store my XCode project folder at the root of the project. So it might look like:
--myApp
--src
--inc
--myApp Xcode
I then drag the src folder and inc folder into the project navigator. This gives me an Xcode project to compile with on the Mac, and then I have the traditional Makefile for compiling on Linux (actually, I prefer CMake for other platforms, but either way works).

Resources