NetBeans Remote Development with additional configuration - c++

I'm trying to use NetBeans (7.3.1) to work on a remote project.
My configuration is following:
My local machine is a Windows 7 laptop. It doesn't have any tools. In particular neither compiler nor debugger. But it does have NetBeans IDE and PuTTY for example.
Source code, Make scripts and (eventually) build results are located on a remote storage shared across servers and "locals". (I might switch to a single server only storage as it is faster but I don't think that it matters at all.)
I'm accessing it using SSHFS Manager. SSHFS Manager takes server name, path on the server, user name and SSH private key. In result it mounts that directory on the server as a disk on Windows. This works fine. (Although some directories, possibly links, are represented as files in Windows Explorer, I don't know if that matters...)
NetBeans project is located on local machine but I don't think that it matters and I could place it remotely as well. But I would prefer to keep it "off source" so that I don't have to add any ignores to version control.
In NetBeans I did procedure described in Remote Developement Tutorial. It seems to be successful. NetBeans connected to the server and found GNU Compiler Collection.
Then I added the project using File | New Project..., there C/C++ | C/C++ Project with Existing Sources. It seems to be successful. All files are visible and all that staff.
The issue is however that our work "procedure" requires us to setup the environment first. So when I log in with PuTTY for example I have to first call setsee with proper argument. And that heavily influences the environment by adding lots of variables for example including:
GCC_HOME which is set to /opt/gcc/linux64/ix86/gcc_4.3.2-7p3, as opposed to /user/bin/g++ which is shown by NetBeans in its GNU Compiler Collection for C++ Compiler and
CPLUS_INCLUDE_PATH which points to some path (while NetBeans doesn't see many includes, probably lacking that path).
So is there a way to tell NetBeans to call setsee on the remote server before doing anything else?

It turned out that setsee is more or less an internal tool. Yet “the core question” remains: how to have an arbitrary script executed on behalf of an SSH session created by IDE, before IDE actually uses that script.
Answer to the “How can I set environment variables for a remote rsync process?” question on Super User says it all.
To summarize it shortly: in ~/.ssh/authorized_keys one has to modify an entry corresponding to the key with which the IDE will log in. There one has to add a command parameter that is a script to be executed after logging in but before “returning control”.
There is also another thing associated with that solution. If the script to be executed within the command option outputs anything the it will break many tools (possibly the IDE as well). Such tools often expect on the output whatever the called tool does. Parsing such output fail then on what the command script outputs.
A simple solution is to use tail. But disadvantage of that is that you loos “progress”. A lengthy operation will look like hung and then output everything in one shot. Also in some cases it simply doesn’t work (for example doing git clone --progress through SSH on Tortoise Git will fail if the command script outputs anything).

Related

How to set a Qt application to use the actual environment variables of a unix-like system?

I'm creating a Qt gui application using a library which searches the PATH environment variable for certain executables, namely compilers, make and cmake.
The problem is that std::getenv("PATH") returns something different in the gui and certain executables are missed. I've tried to use the QProcessEnvironment class to the set the PATH, however, the same problem arises. I can set it to specific paths in my machine but it would be great if it could get the PATH of any machine the application is deployed to.
Strangely if I start the gui using the command-line, everything works out fine! Although I find it unreasonable to ask users to open the gui using the command line.
Any help would be greatly appreciated.
This problem has nothing to do with Qt. You've set the PATH using shell initialization scripts and such, in your own user folder. It'd be a terribly bad idea for the graphical shell to use that path, as a mistake in your shell profile would potentially make the entire desktop non-functional. Of course it works from the command line, since your shell profiles take effect then.
You could, as a user configuration option, extract the shell PATH by running the equivalent of user's $SHELL -c 'echo $PATH', and processing the result.
Otherwise, you'll have to defer to what's customary on the platform, and consult package managers if needed. Different package systems tend to install these tools in different directories, but there is just a few common ones. I presume it'd be enough to cover Ubuntu, RedHat, macports and homebrew, and make sure that you check in "pure" FHS (Filesystem Hierarchy Standard) locations as well.

Seamless (RSE) Remote Projects in Eclipse

I've been trying - without much success - to make Eclipse (for C/C++, but that should be irrelevant) play nicely with remote projects. It would make my life at work much easier if I can set things in the following way:
Run Eclipse from my local Windows machine
Connect (through Eclipse) to the remote Linux development box
Create an Eclipse project from files and directories already created on the remote box
Configure project dependencies and symbols using files and directories from the remote box
Building and running the project in Eclipse is not needed - since this is done with a million makefiles, it's easier for me to just SSH into the box and build from command line. I just need Eclipse to recognize included resources
I tried setting this up with Remote System Explorer (RSE), but couldn't quite get it to work. I can create a connection to the remote box, browse its files, and even convert certain directories to Remote Projects. Once the remote project is created, however, it's useless to me - Eclipse underlines everything that's not a C/C++ keyword, saying it doesn't recognize it (even #include statements of system libraries); equally important, it doesn't allow me to add remote resources to the Paths & Symbols of the project.
Am I missing something here, or RSE just not capable of doing what I need it to?
No, I don't think you're missing something here. I already faced a similar problem when creating/editing remote projects. As far as I can judge, this must be due to the C/C++ indexer not working correctly for remote projects. One action to make Eclipse recognize the #includes is to close and reopen the project through the Project Explorer View. If this doesn't help, try highlighting the #include statement and press F3. Opening the included file seems to trigger the indexer to update the index (although this should also be possible by right-clicking the project and selecting the Rebuild Index function; but this didn't work me). But even after performing these steps, indexing isn't fully functional, e.g., the Call Hierarchy is not working at all (it tells me "File XY is currently not part of the index").
Btw, which protocol do you use for your connection (ssh, ftp, or dstore)? I read some posts that RSE only works seamlessly if the dstore protocol is used. Unfortunately, this wasn't the case for me...

Xcode run script during build

I'm working on a project which has a SQLite database, built by running "sqlite3 [db filename] < [schema filename]" from the Terminal on Mac OS X. I'd like to learn more about the projects system in Xcode, and ideally get it to run this Terminal command automatically when I build the project, additionally copying the created database into the output directory of the C++ project. I've been able to do similar things with Visual Studio before, and I get the impression from the options presented that I can do the same thing in Xcode.
I've added an external build target with the database schema files inside it (so they get source controlled too) and at first it was running with errors that too many arguments were being passed. However, I put single quotes around the arguments and now it runs. But I don't see any output. The file is not generated in the directory I set and I can't find it anywhere else. I was wondering if it took the single quotes as a single argument to sqlite3, but I can't find anything named that either.
I keep finding tutorials such as this one: http://b2cloud.com.au/how-to-guides/precompilation-run-script-in-xcode-4 but it appears that Xcode has changed since they were written and I'm having no luck on 5.0.1. I can't seem to get it to run shell scripts, (hopeful for a workaround) can't find the output of what appear to be successfully run commands, and cannot add Aggregate/External Build Tool projects to the dependencies of my code project, so even if I had it working, it would not rebuild the database with the source code.
I'm more after an outline of the best way to do this in 5.0.1, because I suspect my entire approach may be wrong here.
Thank you for your time.

Building on another machine - Workflow

I'm used to building my source in an IDE and having good feedback in the environment. Currently however I'm writing source code in notepad++, ftp'ing it to another machine with specific environment settings, and then building it there and reading the Makefile output to see that it all checks out. After that, I scp the built executable to the actual device to test it.
I'm curious if there are environments that can simplify this. I suppose I could write a script that ftp's changed files and then runs a command through ssh to build them. But I'd like an environment that will parse the makefile output and give me an build report like in most IDE's. I'm not sure how specific this problem is, or if a lot of embedded systems have similar set ups.
Ideally I suppose I would have a machine with the correct build environment, but that isn't the case :/
I tend to put the file transfer, remote make invocation and whatever else is necessary into some script (having a one-click build is important anyway) and then set that as the build command in my editor. I happen to use Sublime Text 2, which works fine with the error messages I get from building C++ code via make; personally, I don't find editors not supporting this kind of workflow worth using. There are lots of editors which do.
Oh, and I'd try replacing the ftp with rsync over ssh. It's probably faster, definitely easier to automate, and safer.

xcode's executable product for c++ project

I've completed a simple numbers-version of the game "Towers of Hanoi" using xcode's command line tool in C++. Being accustomed to PC compilers like borland's and visual-c, I've attempted to "share" the game with others via e-mail by simply attaching the executable product built by xcode. However, the recipients can't run the program as it shows up in a different format - usually machine code, it sounds like.
After a bit of extensive searching, I'm realizing the complexity of building projects within xcode's IDE and the variations on the build settings/ targets, etc.
Anyone know how to build a self-contained c++ executable to be universally run? I don't go outside the STL library for this game. I'd greatly appreciate any help.
thanks
OS X is based on Unix, which uses plain binary files (i.e. no filename extension) as executables. If they have a certain "executable permission," they can be double-clicked to be run as executables, or run from the command line. However, this permission can't be sent over email - it's metadata within the file system itself, and this makes sense from a security standpoint (you wouldn't want spammers sending you executable viruses over email right?). So when the recipient receives the binary, they'll need to run the following command line command on it, assuming "hanoi" is the name of the binary file:
chmod +x /path/to/hanoi
If you really want to package it as an instantly double-clickable application, you'll need to give it a native UI and package it as a .app, then put that .app (which is actually a folder with the .app extension) in an archive to distribute. Sorry if that's more work than you were hoping for. Hope this helps!
Sharing applications across dot releases of the same OS can be notoriously difficult on the Mac (at least, as far as personal experience goes).
In order to be able to share your application with the least amount of effort, you will need to figure out:
What project type is this? Are you using any resources like images etc?
What version of the OS your friends are using? If they are not on the Mac, you're out of luck (or you'll have to recompile for their OS-es).
If they run Mac, check out that you have the same OS versions, if you have developed on Leopard and someone's running on SnowLeopard your application might simply fail. (I also ran into issues between Mac OS 10.5.4 and 10.5.3 so keep your fingers crossed.)
Check out what sort of hardware you are running. Are you building for your hardware (say, MacIntel) only or are you creating an Universal Binary?
Make sure that all resources are packaged into your application bundle. Make sure your application uses only relative paths.
Check if you are not writing to special folders (i.e. use only temp and/or word-writable locations, if you need to).
I wish I could give a more detailed/to the point reply but unfortunately you'll have to figure out some of the answers yourself (without any other specific information about the error you are getting).
If you're satisfied with a command line tool rather than a double-clickable app, it should suffice to zip it and attach that to the e-mail. Be sure to build universal if anyone you're sending to might be using a PowerPC-based Mac. Oh, and set the deployment target to the minimum OS that any recipient might be using.