Compile one file in QT Creator - qt-creator

How to compile only one file from project in QT creator.
Is there a hotkey?
For example in VS you can press Ctrl F7 and compile your current cpp file.

It is now possible to do it, since at least Qt Creator 2.8.1.
Use Build->Build file <filename> or the shortcut Ctrl+Alt+B:
Or right click on a file in the project view, and there is a Build item in the context menu that builds just that file:
You can track the feature request or vote for it at https://bugreports.qt.io/browse/QTCREATORBUG-106.

Normally if you hit CTRL + B, Qt Creator will call make, which will in turn compile any files that have been modified since you compiled the last time. AFAIK there is no designated key for re-building the current file.
However, all Keystrokes can be configured in the application preferences General -> Keyboard. There are also a number of interesting other commands you might find useful.

Related

Per file compiler flags in Xcode 8.1

I need to add some specific compiler flags only for certain files in my project. I did some googling and found out that this used to be possible in the file inspector in older Xcode versions. I'm on Xcode 8.1, however, and I can't seem to find where I can add custom compiler flags for certain files.
Could anybody please tell me how this is possible with Xcode 8.1?
Go to the navigation bar of your project
Click on your project
Click on the target you want to modify
Click on Build Phases
Look for the file you want to add the compiler flag in the Compile Sources list; in this list you should see two columns: name and compiler flags
Click on the latter column and a popup window should come up; add the compiler flags to that specific file

Is there any way to compile a single file in Xcode 5?

I'm talking about a functionality such that you can just quickly open a .cpp file (C++ console application, nothing regarding Apple ecosystem), work on it, compile and run, without all the project creating mumbo-jumbo. When I open a file with code, all the "Product" options are greyed out for me but after some googling, I found posts claiming that Xcode 5 was to be the first one offering such functionality. Has it been implemented and it's just available elsewhere or were they false rumors and you still have to create a project and import a file there?
Or if you want a shortcut: CTRL + COMMAND + B.
In the top menu of XCode "File - Edit - View" you will see Product.
Click Product->Perform Action->Compile "myfile.xxx"
If you want a shortcut for that command, click XCode -> Preferences-> Key Bindings and set one up.

How can I enable Xcode refactor options for an external build project?

I want to use XCode as an IDE for developing some AVR code. I did the following
1) create new project
2) select external build system
3) indicated i want it to be make, and told it NOT to "Pass build settings in environment"
4) copied my .c/.h/Makefile into the same directory i created the project in
5) added the .c/.h files to the project/target
6) verified that i can build (make) from both command line and Xcode
But I cannot use any of the refactor menu options, or jump to/reveal options. There appears to be no symbol information. Is there no way to use Xcode as more than just a simple C editor that uses an external build system????
If not, it's a bust for embedded development. Please tell me I'm wrong :(
I found a workaround/solution. Create a second target called "Dummy" or something like that, that is based on the Command Line Tool template of type C. Select all the .c files and in the "Targets" pane on the left side bar, check the new Dummy project (or if the options change, as they seem to often, do whatever gestures necessary to make Dummy depend on your C files).
It will create a Dummy directory and a couple of other Dummy files which you can remove if you want. You never bother building 'Dummy', in fact, if it's an embedded project with separate toolchain, likelihood is nearly 100% that it won't compile as a Command Line Tool for OSX anyway. :)
Apparently XCode needs this indirect hint to know that your .c files are indeed real C files and can be parsed/introspected as such.
As you add new .c files which your external build system likely see automatically, make sure you include them as a dependent for the Dummy target.
I was able to get this to work using XCode 6.1. In my case I'm using C++ but it should also work with C as some of my C++ files make C function calls. Here's what I did:
Create a dummy target using: File->New->Target
For the template choose: OS X->Application->Command Line Tool
Click Next
Fill out the Product Name, etc.
Select C++ for the Language field.
Click Finish.
Back in the Project Navigator pane:
Right click on the new 'dummy' target
Select: Add files to 'your project name'
Browse to select your directories/files to add.
Once the files were added to the Dummy target, I could then open a file under my normal target, right click on a method and Refactor, Jump To Definition, etc.

Xcode: Is there a location/flag to prevent a Class from compiling?

Is there a place (or flag) in Xcode for files that you don't want to compile? There are some classes that are/may become part of a project but currently won't compile. The main project doesn't link to them but Xcode still tries to compile them. Is there a way to prevent blocking the rest of project from compiling until these new Classes are "ready"?
Note that for every source file you can specify which target(s) it belongs to - look at the inspector window for a file (Get Info) and then hit the Targets tab. If you deselect a target for a given source file then it won't be compiled as part of the build process for that target.
[This amounts to much the same thing as what Eimantas has said in his answer - it's just a different way of looking at it.]
Look for unneeded files in "Compile sources" in Target -> {AppName} branch. Remove them from there and they won't be compiled on next build (make sure to Clean before you Build again)
In Xcode 8.3.3, in the utilities window, click on File Inspector tab at the top of the window. Uncheck the file in the Target Membership area of the File Inspector. Please see image below.
You can use preprocessor statements:
#ifndef HIDE_<insert name here>
CODE
#endif
And then use:
#define HIDE_<insert name here>
above the aforementioned code in the files you don't want to compile.

How do I Create a link to an executable Installed by Visual Studio Setup Project

I am working on a visual studio setup project. I want the setup project to install the executable for a windows forms project, and then put a link to that executable in the Programs Menu on the target machine. In the Setup Project I clicked 'Add'-> Project Output... and selected the Primary Output from my WindowsForms App. So that should install the program right? Ok, so next I went to the File System on the Target Machine, right clicked on the Primary output from WindowsForms App and said Create Shortcut. I then moved that shortcut into the User's Programs Menu folder.
I tried running the installer and it works ok but for some reason whenever I click shortcut that is in the Programs Menu It actually installs the program before running it every time. Why does it do this? Did I add a shortcut to the wrong thing? If I navigate to the directory application directory and click the .exe file it just opens the program without doing any install. Does anyone know what is going on?
I read somewhere that I could actually make a shortcut in windows explorer that targets my output .exe and then add that file to the installer project but I can't see how that would work on every machine it gets installed on.
I think this is how I did it... been a while tho.
Application Folder
Primary Output From MyProjectName (Active)
Right-Click => Create Shortcut
Then
Users Program Menu
Right Click => Add Folder
Go back to "Application Folder"
Move the shortcut over to the program menu
Rename it to whatever you need. The "Type" should say "shortcut"
Is that kinda what it looks like for you right now? Something in
* User's Program Files
* My App Folder
* Start My Application (shortcut)
And need I say, MS's install projects are a nightmare :) Just open the .VDproj and look. I never thought i'd say I like the csproj xml format, but in comparison...
The problem was not actually in how I was creating my shortcut but rather what the shortcut was pointing too. The executable that the shortcut was targeting was not in the main installation folder and for some reason it didn't like that. Restructuring the install directories a bit fixed it.

Resources