Adding files to a Netbeans C++ project - c++

Background
I was working on a C++ project on a Windows machine, building using a makefile, and editing with Notepad++. I then decided to switch to a modern IDE, partly so that I wouldn't have to keep editing the makefile, so I installed Netbeans (first time I have used this IDE). When I created the project, I specified my existing makefile. All is well, and I can edit and build my project.
There were a couple of source files in the directory which were not mentioned in the makefile. However, they do show up in the file list in grey:
Problem
I can't for the life of me figure out how to add those grey files to the build. Do I still have to edit the makefile? Isn't the IDE supposed to manage this kind of thing?

No, Netbeans won't change your custom Makefile. If I were in your shoes, I'd start a new project and add the source files manually, and after that write any custom build steps you might require.

Related

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

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.

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.

Using Qt with Visual Studio without add-in

I recently started using Qt library and I've got a question.
Is this possible to use Qt with Visual Studio without special add-in?
I want to just design the UI using qt designer and do the rest in VS Express.
How do I do that?
Thanks.
Yes you can, if you would prefer not to use the QtVSAddin it is very easy to use Qt with VS Express without the VS add-in and without having to do any of the uic or moc steps manually. Let QMake (installed with Qt but not part of the QtVSAddin) create your VS project file and do all your project setup in a qmake project file. Whenever you make a change like adding/removing a form or source, modify the qmake project file and regenerate the VS project. Don't modify the VS project file at all, treat it only as a temporary item. QMake will add the rules automatically to the VS project file to rerun uic and moc, you don't need to do anything if you're just modifying source code or forms.
For configuration management purposes I find this a much cleaner approach to use this workflow as you treat the VS project file as only a temporary item (they tend to diff badly and are a pain to maintain in version control).
A couple snippets to help you out:
In your qmake project file ensure you add the following line into it so that VS project files are generated when running on Windows (qmake defaults to generating a makefile).
your_qmake_proj.pro
win32: TEMPLATE = vcapp
Additionally, it's convenient to have a batch file to rerun qmake so you don't have to bring up a command prompt and set environment up (or change directory to your project in a command prompt that already has the environment setup). If you haven't set the various Qt environment variables with Windows (or prefer not to) make sure to add them to your batch file.
makevcproj.bat
set QTDIR=C:\Qt\x.y.z
set PATH=%PATH%;%QTDIR%\bin
set QMAKESPEC=win32-msvcXXXX
qmake your_qmake_proj.pro
pause
CMake is also an answer and it does work with express versions of Visual Studio. I mean if you use the Qt support in CMake you can develop Qt projects in Visual Studio (like I have done for years) without the Qt Addon. I install the addon just for the debug expansion that comes in the same package.
It is certainly possible, but without the add-in you will need to UI and MOC the needed files either before you compile the rest within VS, or through pre-compile scripting.
Specifically:
uic generates the headers from .ui files.
and
moc generates the additional implementation files for classes that has Qt macros in it.
The add-in helps you call these smoothly on the required files before compiling the rest.
It's is possible if you create the UI in QtCreator and manually setup VS in a way that generate the UI and MOC files.
But it's too much work and you can use QtCreator which is an amazing light IDE.

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.

How to create Visual studio solution from make files?

I have a source code for a project with their make files. I want to create a Visual Studio (2005) solution from it. Is there any direct way to do this? can anyone help me please. I spent hours for searching, but couldn't find a way to do this.
Thanks.
Unfortunately, Microsoft removed this capability after VC++ 6.
If all you're looking to do is to build a Visual Studio project from a command line or script, you can use the devenv command to build using the settings in a project.
Something like:
devenv /build debug /project myproj myapp.sln
Ans starting with VS2010, C++ projects will use the MSBuild system, so you can drive builds using that technology.
If you really want a makefile, you'll need to write it up by hand (or maybe there's some 3rd party tool out there that I'm unaware of).
I'm not sure whether this solution can help you. Which I tried and it worked well in my previous projects. It need manually add the files.
Create a blank VS solution/project. Add the source files into that project.
Mark all source files as "Excluded from building". You can right click the files in project explorer and find the setting. So now nothing will happen when you build your project.
In project setting, find something like "Custom build step". Add the commands that invoke your original build command. (You may write different build command for debug/release ). You can also set the post-build actions such to copy your result to some folder....
Now you can edit and build source files.
For my experience, I can even debug it after setting the executable.
Hope this can help you.
If this is a one-off then it is easier to just create the VS project manually in visual studio.
If you are going to need to do this often look at ceating the project in something like cmake or Qt's .pro whcihc an generate makefiles and VS build files from the same defintion.
Do you want to use the makefile to build? You can create a project from existing source in VS 2005 and setup the project to use make to build (and the wizard will take you through all of this).
I am using VS2010.In order to build you can create a project from existing code. In VS2010 you can create project from existing code File->New->Project from Existing code. You can specify the other parameters and then ready with the solution. I did not go with make file but followed this approach which is working great.