Can't change system variable "Path" for netbeans - c++

I downloaded Netbeans because I wanted to start learning C++. I downloaded the compiler, debugger, and make utility from cygwin. In order to complete the process of setting up my IDE I need to modify the system variable Path to reflect my new cygwin installation.
So here is what I do:
type var into windows search
click on Path in the system variables
Here is where the issue arises. The instructions I am reading tell me to edit the Path variable, but the buttons are unclickable. They remain faded even after clicking Path. When I double click the Path variable I hear the windows "error" chime.
I don't know why I can't modify the Path system variable. I have ensured that my account (the only one on the computer) is an administrator. I am running windows 7 if that makes a difference.
Thanks,
Alex

I solved it just now. Even though the end destination is the same, typing var into the search bar opens the environment variable window, but prevents editing. However, if you right click Computer, select properties, select advanced settings, then click on environment variables, even though you're in the same location, the variables are then editable.

Related

Qt application has unexpected QDir::currentPath

I am using QSettings in my Qt application to store prefences and all was fine until I start to run it on Linux mint 19. Default location for settings file is application folder, but now it is creating in users home folder.
QDir::currentPath() returns home folder, if I am running application by double click, and correct executable location if I am running it from terminal. I have never seen this before. Maybe somebody knows how to fix it and run application by double click from it's own folder.
Don't depend on current working directory (returned by QDir::currentPath()), because that can be basically anything. Looks like your desktop environment's file manager sets current directory to home folder when you run software by double clicking, and this is generally sensible, because that is usually what user would want, when opening files from the app etc.
If I read correctly what you want, that is path to application folder to store settings in, you need QCoreApplication::applicationDirPath(). But note that doing this will force you to install the application to user home folder (because you can't write to system folders like /user/local/bin, and you shouldn't change this by changing permissions, either).
Based on comments, it seems QCoreApplication::applicationDirPath() gives wrong directory, but QCoreApplication::applicationFilePath() gives correct path. If that is really the case, then take the file path, and remove the executable file from it. However, looking at the Qt source, this shouldn't be possible because applicationDirPath() already does just that...
I recommend you instead use QSettings as documented in its basic usage.

How do I turn my C++ code into a .app file? [duplicate]

I am building a C++ OpenGL card game in Xcode 4.3.3, with the intention of running it on both 64-bit and 32-bit Macs, which is not my problem. My problem is that I have reached a point in the development of the program where I would like to test that it works on a different 32-bit Mac (mine is 64-bit) without having to install Xcode. This, obviously, requires me exporting it as an .app. I can find and run the exported Unix Executable File from my project, after some cd'ing, through Terminal, but that is undesirable for me and the intended audience of the program. I have trawled the google and Stack Overflow, looking for anything to help me, but all the things mentioning Archiving seem to have been unsuccessful with my particular project, and I think that's because it's a C++ command line tool project. So, can someone please help me export my project as a .app?
Thanks in advance.
The simplest way of doing this would be to create a Cocoa project, go to 'build phases' and remove all the objective-c frameworks from the 'link with libraries' build phase, remove any objective-c files added by the template (app delegate, etc.) and then replace main.c with your main.cpp file.
There's nothing really special about a Cocoa project except for the fact that it links against Cocoa and calls NSApplicationMain() from its main() function.
There are also a bunch of .plist entries used by Cocoa which you'll no longer need. But they won't affect the way OS X treats your application.
I'm searching for an XCode Settings solution but here's my current way to create an app:
You have to take your binary file (let say myapp) and put it in "MyApp.app/Contents/MacOS/myapp" then it can now be launched as a .app. That's a trick.
Just go to the targets folder in the file navigator on the left, and there will be an executable listed there. Left click on that executable and click "show in finder". (I'm describing from memory so I may have the exact details wrong.) The file path is ridiculously long (there is an arbitrary alphanumerical pathname involved, I have no idea why), so you probably won't be able to find it with the command line.
If you want you can change the extension of the file from nothing to ".app", it shouldn't affect the nature of the file at all. Also if you want a custom icon, you can "get info" on it in the finder, then click on the icon in the info window, and use Cmd-V to paste it in (obviously you have to have your icon copied to the clipboard). There is also a way to do this inside of Xcode, but I don't remember it.

Netbeans/C++ add environment variable at make

I need to set a variable that is checked in the makefile(i.e. at compile time), but I can't find it in the project properties.
I right-click on the project, but can't find a place to set environment vars, except in the Run but even there it seems I can't add a variable (nothing happens when I click on Add after expanding the ...).
What am I missing?
As a side: Netbeans probably will run a shell before issuing the commands like make, what kind of shell is it? how can I configure it?
Judging by your screenshot that you are on OSX, you should be able to set an environment variable by replacing "${OUTPUT_PATH}" under Run Directory with FOO=BAR;"${OUTPUT_PATH}". This is normal POSIX syntax for running a program with a specific environment variable or set of variables set, and can be used at the terminal as well.
Edit: In Netbeans, to set an environment variable for a specific action, right click on project, go to Properties->Actions->{Action}->Set Properties: Add Env.FOO=BAR.

QT: Launch default exporer on a directory selecting a file

My application displays a grid of images. When the right mouse button is clicked a context menu is displayed where the first option is "Show in Explorer".
I was able to launch the default explorer on the directory by using:
QDesktopServices::openUrl(QUrl::fromLocalFile( directory ));
However I want also the file to be selected.
Is this possible? I suppose it should be, as many apps can do that.
openUrl is not suitable here. You need just start another process (with QProcess start or startDetached) with Windows explorer special arguments:
explorer.exe /select,"C:\pathTo\file.txt"
Ok, I want to thank #Chernobyl for his useful help.
However I've found a general solution posted here:
How to "Reveal in Finder" or "Show in Explorer" with Qt
It wasn't compiling at first because the QtCreator code is using a class called Environment which I tried to add to my project but that file then also includes others, etc. I checked and they are using it just to see if explorer.exe can be found on the system path. It was not so important (to me) so I removed that check and then I tested it. It's working perfectly. It's also supposed to work for Mac and Linux.

Why does not Visual Studio 2010 "unpack" system variable?

I was trying to set up an Ogre3D application and I set an "OGRE_HOME" system variable to the home directory of the SDK. Then I set project properties, like include directories in the Project Properties, using the $(OGRE_HOME) system variable. But when I tried to compile the application, the compiler did not find the header files, so I had to "hardcode" the SDK path to the project properties.
I set the variable first with the setx command, then I tried moving it to system variables but it did not help. However I did not try to reboot the system.
MSBuild does expand environment variables. $(OGRE_HOME) should work just fine.
The only problem is that Visual Studio caches the values of these environment variables heavily, so changes that you make will not be immediately reflected.
There are two general ways to change the values of environment variables, and both of these go wrong with VS:
Changing the values from the command line only affects applications that are launched from the command line. Since you're probably launching VS from a shortcut through Explorer, it won't inherit the new values.
Changing the values through Computer Properties should normally work because that dialog broadcasts a global message indicating the persistent environment variables have changed. Unfortunately, VS doesn't seem to listen to these messages and update its cache.
But, restarting (or logging off and back on) should fix the problem, as this will cause VS to refresh the values of the environment variables.
It's also worth noting that user macros are an alternative to environment variables. VS 2010 provides a very robust way of implementing these through the Property Manager. You can create a project property sheet with your settings, which can then be attached to multiple projects so that they will all inherit these settings. It doesn't work outside of VS, but it can be quite convenient if you do all of your development work there.