Cannot add test in Netbean C++ project with existing code - c++

So, this is what I have done.
I had a c++ project that I imported in NetBeans. Since the code had its old makefile I made NetBeans use it. I then added the logical folder Test Files (and included cppunit libraries in its linker). If I now try to add a cpp unit test Netbeans complains that I do not have a Makefile and does not let me create the unit test.
The exact error message is:
Makefile is not detected. Test targets will not be added to makefile.
How should I modify my old makefile so that Netbeans will recognize it?
Thanks for the help,
Michele
Additional information
I followed the instruction in http://www.oracle.com/technetwork/articles/servers-storage-dev/howto-add-unittests-ide-1731716.html#About on adding test to an unmanaged project but I cannot understand point 6. What should I add to my makefile? Can someone give me an example?

Right-click on the project name in the Projects pane - you'll get a pop-up menu with first line New, place cursor on this line - another pop-up menu will be opened, left-click on the CppUnit Test... in this menu. You'll get a pop-up window with some settings you can adjust.
After you click Finish in this window the NetBeans will create a directory with test skeletons and add new targets to your Makefile.
Good luck!

I ran into the same problem. It appears in NetBeans you MUST have the Test Package, which is where you would add your unit tests. If you create a C++ Application in NetBeans you will see the Test Package in your project. If you have a project that uses a Makefile that was not generated by NetBeans, then it appears that there is no way to add this Test Package to your project. I would be very happy to be wrong but this has been my experience and from all I have read it appears to be true.

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 can I do C++ Unit Tests in Netbeans?

I attempted to follow the tutorial here to get Netbeans unit testing setup for C++. It talks about a "Select Elements" portion of the test setup wizard in which one selects the parts of the actual project that are available to the test. This stage in the wizard is absent with the wizard starting on "Name and Location":
When I create a unit test without this part of the wizard, I am unable to include any headers from my project unless I include it in the format #include "../Header.h" and, when I do that, g++ has problems linking the included header to the corresponding implementation.
What am I doing incorrectly and what do I need to do to have my unit tests work correctly?
NOTE: I am trying to use cppunit, but, the dialog is missing "Select Elements" for all 4 available testing formats (simple C, CUnit, simple C++, CPPUnit).
The "Select elements" part of the wizard comes up when you activate the wizard by right-clicking the .cpp-file or the .h-file and click "Create Test".
If you do "New .. / C/C++ tests/.." this part of the wizard isn't there.
I am unable to include any headers from my project unless I include it in the format #include "../Header.h"
There seems to be an oversight by the template/wizard writers to not address the fact that your tests lies in a directory tests. You can fix this by adding your project folder as an -I include directory switch. Use an absolute path.
Linking should not be a problem since the compiler targets the Build directory. If you do have problems with linking check the properties of the linker options in your CPPUnit test project folder.

Importing C++ project in Xcode

How do I import a C/C++ project(NS3, GNU-Radio) to Xcode 7? The main reason I want to do this is to get autocompletion and Quick Help definitions. This can be done in Eclipse by:
File > New > 'Makefile Project with existing code'
It would be nice to have the debugger working as well but not necessary
The answers I have found are mostly for Xcode 4 and seem not to work on Xcode 7
Thanks
The easiest way is to drag and drop all files of the Sources folder into project Navigator of XCode directly from the file browser. That will pop up a wizard to import files into the project. At this point you will need to check the application name into the "add to target" field. Failure to do this would include the files into the project but without actually compiling them.
You do not need to update the include path because the Wizard has already do that for you.
Here is an example: https://www.youtube.com/watch?v=Fqovf9OghSM under OSX if it helps :)

Project dependency in Eclipse CDT

I'm using eclipse for the first time. I'm a seasoned VisualStudio user, so I'm trying to find similar functionality in eclipse. I have two projects, A and B. Project A spits out libA.a when it's done compiling. Project B links against libA.a. Here is my problem.
I compile project A then project B, everything is fine.
I make a code change to project A that requires a build of project A.
I try to build project B, but it states that no changes have been detected.
How do I make project B aware of the output of project A?? Currently I'm having to do a clean build of project B for it to re-link against libA.a.
Thanks.
EDIT: In my ProjectB->Path and Symbols->References tab, I have project A checked. This doesn't relink after project A is rebuilt.
Try the below settings:
Go to properties of Main Project → C/C++ General → Paths and Symbols → References
Tick all the dependencies.
You go into Project Properties of Project B, select Project References and make it reference (depend) on Project A.
Edit, appears to be a known bug
One can work around this problem by using the touch command.
In Eclipse, as part of C/C++ Build/Settings is the tab 'Build Steps'. In the pre-build steps command line, enter touch filename.
filename is any file in your application. This could be the file with main(). This could be a special file just for this workaround, touchdummy.c, which can be a tiny file, which compiles quickly.
When the application builds, even if you didn't change any sources, the touch command causes make to rebuild the application. If the library was rebuilt, then the application gets rebuilt with the new library.
One can read about how touch affects the date/time of the file here.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html
Edit: The exact command in Eclipse would be touch ${ProjDirPath}/src/main.c
Edit: This command should work, but it appears that if the 'main' project did not change, the pre-build step is not executed. Also the touch command causes eclipse to prompt to reload the file it touched. A large annoyance.
Eclipse projects depend on each other by virtue of the checkbox in the project's properties (dependent projects?) which is how Eclipse decides which to build. You can set this yourself, but it's usually set when you change your Java build path.
By default at least with QNX C++ projects, it WILL NOT check for changes in other projects.
Right click on the project, and expand "check dependencies on/off"->"check user headers only"
It seems to work, roughly...
It appears to do a makedepends on the code, and adds *.d files to the output folder which are simply depends file that list the header files.
Note: these do not appear to get regenerated, and get out of date - I do not know how to regenerate them.
For Project A (library):
Properties>C/C++ Build>Settings>Build Steps>Post-build steps> touch -m ${ProjDirPath}/source/build/build_updated.cpp
You should create folder "source/build" firstly and don't add in that folder any other files.
For Project B:
Properties>Project References> check Project A
Properties>С/С++ General>Paths and Symbols>Source Location>Link Folder>Link to folder in the file system> find and pick "source/build" folder which you created for project A before.

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?