How can I get "go to definition" working in a JUCE project? - c++

I'm trying to get "go to definition" working for a JUCE project created with Projucer. I've tried both CLion and Visual Studio Code, but they can't seem to find definitions that live in the JUCE libraries.
I'm on Ubuntu. Is there a blessed path for this? I'm normally a vim user, but I'm willing to try any IDE.

I've just figured this out!
In VS Code go View and Command Palette and type C/C++: Edit Configurations (UI) which will take to the IntelliSense Configurations page. Under Include path, on a new line, specify the path to JUCE e.g. ~/JUCE/**.
Note: The two stars are needed to tell VS Code to look through subdirectories.
This will create a hidden folder .vscode in your project folder with this configuration.
You will need to repeat these steps for each project you make.
Definitions and code completion should now work.
To compile your code, in your project folder go Builds then LinuxMakefile and in a terminal run the command make. Finally, go to the builds folder and run your project ./exampleProject.

You need to add the JUCE/modules folder to your search path, not the top-level JUCE/ folder!
If you're using the Projucer, you'll also need to add the JuceLibrarySource/ folder to your search path.

What I ended up doing was using FRUT to convert my project from a Projucer project to a CMake project. CLion was able to understand the CMake project, and thus, the "go to definition" and autocomplete features started working.

Related

How can I tell Visual studio where my additional .dll files are?

I have recently switched my IDE to Visual Studio 2019 for C++ projects. I easily followed a tutorial into setting up a new library like SFML into visual studio, and tell it where the additional include and library directories are.
But there is something else that is required for it to work, which are the .dll files. Every page I followed, even the Documentation by the SFML website, it says that they have to be in the same directory as my project. That means I need to copy-paste the 7-8 files into my project directory. This really makes the folder look untidy. I would like to create a new folder and tell Visual Studio where those files are. I tried going doing this
Project -> Properties -> Linker -> Input -> Additional dependencies
Usually, the lines that would work are
sfml-system-d.lib
sfml-window-d.lib
...
I tried doing $(ProjectDir)valid path\ sfml-files.lib but this gives me the linker error, saying that It could not find the file.
If I simply move the .dlls into a folder without doing anything, the code would compile and link fine. But when it runs, Windows gives me a pop-up box with the same error message.
Here is how it currently looks
Looks really messy, I just want to be able to move them into dependencies like how src contains the source files.
How can I achieve this?
As it is now, it works perfectly fine. The issue only occurs when I try to create a new folder.
I hope I have covered the important information required for a good answer, If not please let me know what more I should add
Microsoft Visual Studio 2019
Currently running 64-bit platform with Debug configuration. Hence the -d suffix
You could create a path environment for your specified directory, which is like drescherjm’s suggestion. The steps:
Right-click “This PC” -> “Properties”-> “Advance System settings”
Click “Environment Variables”
In the System Variables group, edit “Path”
Add your directory, for example: ”D:\ SFML-2.5.1\bin”
Restart your visual studio and re-open your project
The easier solution might be to put them in the x64 subdirectory. This allows you to have various builds side by side (x86/x64, debug/release).
Since this x64 directory is where the EXE is located, it is the first directory searched for DLL's. It will take precedence over the Path solution suggested in the other answer. The Path directories are searched last of all.

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.

Importing c++ projects to eclipse

I use eclipse Neon from a ubuntu 15.04 virtual box.
I want to run medical image reconstruction framework gadgetron from https://github.com/gadgetron/gadgetron. I downloaded zip file and extracted the gadgetron code zip folder into eclipse workspace. The folder structure shown below:
Through menu New -> Makefile project with Existing Code, I imported the gadgetron code into eclipse IDE. The eclipse screen looks like this.
When I try to build the project, I get an error make:*** No rule to make targe 'all'. Stop.
How can I build and run this project in eclipse IDE?
Check the README of the project. You imported as an project with an existing makefile. Eclipse looks for the Makefile in the root directory of the project and in this case simply couldn't find one. You can either tell Eclipse to use a specific Makefile or create one in the root of the project.
Edited: Adjusted answer to show final solution.

Eclipse CDT Kepler Importing Makefile project

I would love to import a Makefile project from Eclipse, and have all the different includes path that the compiler uses to create correctly my Eclipse project.
Unfortunately, those path, specified on the command line by a "-I" don't show up in Project Explorer and I have to add them by hand.
I am currently importing the project using the standard "Import project from Makefile" built in Eclipse.
If I'm not wrong there was an autodiscovery option in older versions of Eclipse, but it's not there anymore.
How do you do for having all your include paths set up without too much hassle?
The trick is NOT to use
File->New->Makefile Project with Existing Code
but to use
File->New->C++ Project
and then to select
Makefile project->Empty project.
After you set up such a dummy project, you simply copy your existing source to that project directory, hit F5 (i.e. Refresh) and change the build command to use your Makefile.
I was able to get this to work using Luna. I imported using File->New->C++->Makefile Project with Existing Code.
Prior to launching eclipse, you have to be sure to source any files that set required environment variables.
I did have some build options which were not the standard all and clean, so I had to add those configurations individually.
source files to setup your environment.
Launch Eclipse
Import C++ Makefile project
Setup Build options.
Click the hammer.

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?