I'm using Eclipse + CDT for a project.
I'm using the "generate Makefiles automatically" option from my build settings.
I have in one file the date and some values that must be actualized every time the project is compiled. But since I don't change every time this file the compiler doesn't refresh it.
Is there any option so I can have a Phony target?
if I could just add some lines to the makefile will work
rm -f *.o target
but this will be removed the next time I update my project.
I found that in the settings >> c/c++ build >> behaviour there is an opportunity to write some clean variables. Could this help? I tried to write the file name but this does not work.
You can give CDT a pre-build command. For me (3.6.2 on Linux):
Project → Properties
C/C++ Build category
Settings sub-category
Build Steps tab
Pre-build steps pane
Enter a command to delete the object file in question (rm f.o, or somesuch)
You can user make clean on Pre-build steps
I added the following to the Pre-build steps and it seems to work great:
del ${CWD}\addtional_dir\file.o
Related
I'm practising clean code and I installed sonarlint as a static testing tool to help me write clean code. after installing the editor rises this notification
SonarLint is unable to analyze C and C++ file(s) because there is no configured compilation
database.
after some searching, I found that I should add a file with a name
compile_commands.json.
this file should be exported automatically by cmake after adding this option
CMAKE_EXPORT_COMPILE_COMMANDS
where can I add this option in VScode.
this link is where the vscode redirected me to creat the required .json file
I am assuming that you are using CMake for your build. If that is the case then add the following line to the CMakeLists.txt
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Then build the project and the database will be created for you.
When I want to run my .mas2j file in Eclipse, I always have to right click the file and then select "Run as Jason application". Is there a way to add a shortcut to do this?
Jason's "Run" button should be added to eclipse toolbar ("Step 14" of jason eclipse-plugin installation guide) and it is supposed to work. Anyway, you can save some time using shell, following instructions in jason's github page:
git clone https://github.com/jason-lang/jason.git
cd jason
gradle config
And run a project using a command like bellow:
jason examples/gold-miners-II/miners.mas2j
Another way, and actually my recommendation is moving to JaCaMo (which has Jason embedded). JaCaMo offers a gradle script for your projects. You can easily download JaCaMo from the repository and create a project from zero in one shot (first, go to your project root folder and then type):
curl -s -O http://jacamo.sourceforge.net/nps/np07.gradle
gradle -b np07.gradle --console=plain
After downloading JaCaMo, the script will ask you to type a name for your project, for instance, "test". So, go to "test" folder and type:
gradle run
The just created JaCaMo project should launch after this command. Besides good compiling performance, another advantage is that gradle will manage package dependencies.
This is usually the issue with uncategorized commands in Eclipse. I had the same issue with the Run JaCaMo Application option. In order to see all your plugin commands:
Go to Preferences -> General -> Keys. Click on Filters... and de-select Filter uncategorized commands then Ok.
Then you should be able to find the desired command in the Command list and add a preferred Binding.
Note: If Eclipse offers a command, it should be listed in the pop-up window that appears when hitting the Show a table of all available commands button of the Oomph toolbar. The table shows all the available commands, where you can find them, and all the defined shortcut keys.
I have a CMake project (native Linux) which I imported into Eclipse using cmake4eclipse.
The build process includes downloading some sample data which is rarely needed in production use. Currently this step fails (causing the whole build to fail), which is why I would like to skip it in the build.
The build chain supports skipping tis step. Running CMake from the command line, I would simply do -DSAMPLE_DATA=n.
With cmake4eclipse, where would I specify this option? I have tried adding it in Project > Properties > C/C++ Build > CMake, but it takes no effect.
In Project > Properties > C/C++ Build > CMake, on the Symbols tab, add a new variable. For -DSAMPLE_DATA=n, add SAMPLE_DATA, type STRING, value n.
After that, on the General tab, check “Force cmake to run with each build” and build once. For subsequent builds you can clear the check mark again—you just need to run this once so Eclipse/CMake will pick up the new configuration.
add it on the CMake|Symols tab in the project proerties.
I use CMake as a build manager for a C++ project. All my sources are in a src subdirectory, and I created a sibling build directory. Following the directions from https://cmake.org/Wiki/Eclipse_CDT4_Generator, the build commands I use are:
cd build
cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug ../src
This creates the .project and .cproject files used to import an existing project in Eclipse. In the IDE, everything seems to work perfectly, except that the make target does not work.
When I click on a build target, the CDT build console opens, but nothing occurs. Also when I click on Project / Clean in the Eclipse dropdown menus, nothing occurs. I checked the commands invoked by the targets, and they are of the form /usr/bin/make -j8, which should work.
Can anyone help me get the make target work ?
An automatic update to CDT just occurred and everything works now. So check for updates I guess.
Hope this is followed to create target....
The docs for eclipse says:
Your project name should be different from your executable name and different from your build folder name. Otherwise, Eclipse will NOT pick up your executable as you build them. Since my build folder name is certi_build, a CMakeLists.txt file like below should work (notice the difference in project name and executable name)
PROJECT(AwesomeProject)
ADD_EXECUTABLE(AwesomeProjectMain
main.cpp
util.h
util.cpp
)
I have a C++ project with 3 .hpp files and 1 .cpp file, and a custom Makefile. The code and the Makefile for this project already existed, so I right clicked in the Project Explorer, and did Import->Existing Code as Makefile Project I named my project and pointed the location to the root dir of the project which contains all of my files. And I selected MinGW GCC as my toolchain because that is the compiler that I have. Then I went to Project->Properties->C/C++ Build and unchecked Generate Makefiles automatically
Then I changed my Build directory by choosing File system and navigating to the root directory of my project which contains all of my files. The Build directory is C:\Users\Ryan\Desktop\School\CSE\CSE 100\pa1-rbridges
Then I changed the Build command to make -f C:\Users\Ryan\Desktop\School\CSE\CSE 100\pa1-rbridges\Makefile bst where bst is a target in my Makefile and my Makefile is at that location. When I click the hammer on the toolbar to build my project, nothing happens. When I try to run my project, I get Launch failed: Binary not found.
I just want my project to use my Makefile and build properly.
I have searched Google and stack overflow for hours trying to figure out how to get this to work and have had no luck. Any help is appreciated.
The solution to these sorts of problems usually begins with breaking them down.
First try and build build from the command line. Does the "make -f ..." work from the command line?
It could be an issue with MinGW not working properly.
It sounds like you have done everything correctly as far as eclipse goes. You may find a clue in the eclipse console window.
Too late for giving an answer. But this is for the other people who end up here.
You need to create a new run configuration in Run->Run Configuration... for your project, and then type a name for the output binary file like Debug\name.exe in 'C/C++ Application' box. The name must be the same as the project name.