in eclipse cdt, how to build target other than the first one - eclipse

I am quite newbie in using eclipse cdt. I have a makefile project, and have more than two targets in my Makefile. Say the Makefile is as follows,
all:
...
t1:
...
t2:
...
it's easy to make CDT build target 'all'. However, how can I build targets other than the first one, like t1 and t2? Thanks.

In eclipse, go to:
Window > Show View > Make Target
In the view that opens up, right click your project, click on "New".
Give your target a name, say "T1". Uncheck the "same as the target name" and put the "Make Target" value to t1.
Same for t2.
The next time you want to build your targets, look at the Make Target view that you opened, and double click the target you want.

Related

Xcode Unable to add test target to existing swift project - Target to be tested is grayed out

I have an existing project that I am trying to add unit tests to.
I'm on Xcode 10.1 and project is purely in Swift.
I start by clicking on "New Target..."
In the first dialog I am able to choose the project but the dialog box for "Target to be tested" is grayed out.
I have tried to go ahead and add the test target without choosing and this results in my test bundle not being able to find my existing classes - "No such Module error"
Here is the dialog for adding the test bundle:
Not sure what I'm doing wrong to prevent the this selection
Thanks for any help!
In Xcode 10.2.1, with your project open, click on the diamond with a dash in it:
Then down at the bottom left of the project window click on the '+' and select "New Unit Test Target".

How to add two compiler flags in Xcode

I would like to add two compiler flags, one for ARC (-fno-objc-arc) and one for warning (-w). Anybody know how to add two compiler flags in the Xcode build phase for a particular file?
Add the compiler flags under your Project -> Target -> Build Phases, just separate the flags by a space.
In Xcode, clic on your project file to see the pane with your target(s) and then :
Select the "Build Phases" tab
Unfold "Compile sources"
Search for your specific file
Set your compiler flags on this particular file by double-clik on this column.
Hope this helps
Select your project in the project navigator in the left-hand panel, select your target, then select Build Phases. Expand Compile Sources and double-click the file you want to set the compiler flag for. Repeat for each target you want the changes to apply to.
Select blue project file
Select "Build phases".
Disclose "Compile Sources".
Double click on file that you want to add flags.
Then set flags separated by space.

Eclipse Maven Build and Test with One Button

The most common build activity I do in Eclipse (other than allowing auto-build to do its thing) is to perform a "Maven Build..." with parameters of clean and package. This runs all my tests. m2eclipse does a great job with this, and I like the output. If a test breaks, I then jump to using the JUnit plug-in, the debugger, etc.
I've used "Organize favorites..." under the Run (and Debug) button's drop down menu to make this kind of build "permanent" and somewhat easy to access and use.
But not easy enough.
What I have now is a button that morphs from moment to moment, based on my last activity, what file I have open, or what item I have selected in the project window. Yes, I can click the down-arrow next to the run button, select the favorite for "clean-and-package" but for something that I do hundreds of times a day, that's too difficult.
I want ONE BUTTON. A big ol' button on the tool bar that I just click and boom goes the dynamite. I'll also accept a way of assigning a hot key to my build favorite so I can press, say, ctrl+r or something to run my favorite item.
What'cha got for me?
I've rediscovered key bindings in Eclipse. It's not exactly what I want, but it works well enough, I suppose. I simply bind F7 to Maven's test hook. It's not the same as "mvn clean package" but it'll do until I find a better solution.
Here's how I did it:
Open preferences
Open General->Keys
Search for "maven test" (or "run maven test")
Select the Run Maven Test entry
Click on the field labeled Binding
Press F7 (or whatever keystroke you want to bind)
Probably best to set the When field to in Windows
Now, when you press F7, eclipse will run "mvn test".
For whatever reason, and I'm sure it's a perfectly good one, the m2eclipse plugin authors didn't provide a "Run Maven package" hook. Sigh.
It looks like there's a couple of ways to do this - none directly in Eclipse:
Create your own small plugin that defines the key binding, see here: eclipse: put keyboard shortcuts on specific launch configurations
Use Practically Macro - also see here: Assigning a keyboard shortcut for a specific Eclipse build configuration
Use some form of scripting, e.g. this: http://mackaz.de/72
If you create a Maven Run Configuration and put a number as the first character in the name, then you can use Shift-Alt-X Ctrl-M N, where N is the number you gave as first character in the name. For your case, do the following.
Right click on your project, select Run As and then select Maven
build... This will open a dialog to create a new Maven Run
Configuration.
Make the name of the configuration 1 - test.
Put test as the goal.
Press Apply and then Close.
Type Shift-Alt-X Ctrl-M 1. This will select the configuration you just created.
Press enter will launch it.

Specifying multiple Eclipse's Make Targets with control of order/dependence?

Is there any way to specify multiple Make Targets to be built by the build process, and if so, then it is possible to control the order or define dependence of the Make Targets in a managed C++ project?
If you want to do this in eclipse and at the command line, I'd edit the makefile to add a targets depending on the items. Make will figure out the order if needed.
If it's ok to have this work just in the Eclipse project then add a custom make target
In the "Make Target" view, click "Create a Make Target", uncheck "Same as Target Name".
List your multiple dependencies all in the "make target" edit box.

build eclipse project when antoher project is requied

I had wrote an app( android A) and I would like to build. The problem is the following: I had another android project(B), witch I want to start from the "A" one when the user click on an icon. I had added to the "A" build path the "B" project, but it isn't works. As I trying to build the "A" the app going down and said: "Class B not found on com.pack.BMain,".
Any idea or tutorial ? I could not found neither.
Right click your project > Properties > Android:
At the right side of the pop window, find Library part, click Add button to add project you want to reference.
There are a few things you can try. As you mentioned, make sure B is in A's build path (Right click on A in package explorer, Properties/Java Build Path/Projects/Add). You should also make sure that your run configuration includes both projects. Go to Run Configurations/Your configuration/Plug-ins/ and add A, then hit Add Required Plug-ins, or add B manually. Make sure Validate Plugins returns no errors.