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...
Related
i have the following problem. I am using Netbeans 8.2 on Windows 7. I configure a C/C++ Build Host which is a linux system. On this linux-system i have a c/c++ projekt. Then I create a new project with right-click on this host -> New C/C++ Project and than --> C/C++ Project with Existing Source.
This work fine. On my windows-machine i can change the code, can compile and run the project. This all happens on the linux machine.
But the project and the sourcefiles only exist on the host-machine. Is there a way, that each compiling the data (source-files and the project) was copying to the local-machine so that the files exist local and on the host?
Greetings
I'd discourage such a way of keeping code in sync between two machines. What you would like to achieve is having code (and I count the project files as code here) in sync between two machines. That you work on one and compile on the other is not that relevant here.
The - in my opinion by far - best way to keep things in sync is to have some kind of version control system, i.e., a repository. I prefer git in almost every case. You can - and should - regularly commit your changes to a repository, and then you can simply push/pull the changes to keep all your machines in sync.
Arduino has some good C++ libraries which I would like to use on a PC platform. Another advantage is that one can test and debug Arduino code on a PC. It is much easier to do debugging on a PC.
One library I am particularly keen on is the String library. https://www.arduino.cc/en/Reference/String
Is it possible to somehow import the Arduino String library into a C++ IDE like Visual Studio given that the Arduino library is open-source? How can this be done?
I have been struggling with this issue on and off for the last three months, and I have spent a few hundred hours staring at my computer screen, trying stuff, documenting the results, trying other stuff (repeat). I have done a fair amount of digging on the internet and have found very little that constitutes a definitive resource on this topic. That being said, here is what I have found that WORKS. One caveat is that these instructions are based on ESP32 hardware. Note that this is still a work-in-process, as there is some clean-up left to do. Also note that this avoids having to do the manual/command line tasks such as "makefile". If you are coming from using the Arduino IDE environment you will probably appreciate this.
First of all, some details on the development environment:
Install MS Visual Studio Community Edition (free). I installed "Desktop development with C++ option" (Visual Studio link)
Note that I am developing code for an ESP32 module. There are lots of different modules to select from, they are low cost (~$7 on a breakout board), are very powerful (compared to Arduino hardware) and have Bluetooth and WiFi embedded. If you are using some other hardware then some of the remaining steps may not apply/will need to change.
Install drivers (these are used so the ESP32 gets assigned a COM port automatically) (Silabs link)
Install VisualGDB (download link) for MSVS as described in this link: (VisualGDB tutorial) Note that downloading the ESP32 toolchain as described in the link takes a long time (an hour?), be patient.
Note where the folder \SysGCC\esp32 is located on your computer (most likely in the root of your C drive). This is the ESP32 toolchain that you installed on the previous step.
As part of the VisualGDB install step that is described in the VisualGDB tutorial, you have to change the "Path Mapping". I was prompted by the install to download CMake.exe from VisualGDB at this point. In the field "Absolute Paths (starting with /)" you will need to enter the path to SysGCC that I described above (mine was C:\SysGCC\esp32)
At this point you should be able to connect an ESP32 module to your computer and use the "New Embedded Project" wizard in VisualGDB to create a simple project. I generally choose "LEDBlink". Note that most of the ESP32 boards I have used have the built-in LED on GPIO 2, not GPIO 5 (which is the default in the wizard).
So far, so good. Confirm that you can blink the LED. Clap your hands, shout with glee, grab a beer, or do whatever else you want to celebrate. At this point we have not really done much to help the importing of Arduino code, so here is where the fun REALLY begins.
Note the location of your LEDBlink project folder on your hard drive.
Download the Arduino core for ESP32 from Espressif on Github.
Copy all the *.h, *.c, and *.cpp files from your downloaded Arduino Core into your Blink project folder, EXCEPT the files that are in the "variants" folder. I ended up copying 77 files. In fact, what I did was first create a new folder called "bulk libraries" to copy all the source and header files into, in order to make it easier to perform this step for each project.
The "variants" folder contains a load of subfolders, each containing one file named "pins_arduino.h". You have to find the folder for your particular ESP32 module, and put that particular "pins_arduino.h" file in your project folder.
In your project source code, add the following line:
#include "Arduino.h"
Build the project and you should get no errors.
Note that in the MSVS Solution Explorer window for your project, under External Dependencies, you will see a list of all the *.h files that you copied into the project folder. This won't happen right away, but in the lower left corner of the MSVS app you will see a bunch of things going on in the background, parsing files etc., THEN the External Dependencies will appear.
Now in app_main() add the following lines:
initArduino();
Serial.begin(115200);
If you rebuild the project you will get a few errors during linking, because all of the file references to the *.cpp files are not (yet) included in your project.
In the Solution Explorer, right click "Source Files" and "Add Existing Item" and add all the *.c and *.cpp files to your project (not the *.h files)
Rebuild your project. You will most likely get some errors of "(something).h: no such file or directory". That is because at the time of this writing, the Arduino core provided by Espressif is not complete. In the Error list, note the file location of the error, and REMOVE this file from the project in the Solution Explorer. For example, I had the following error:
"vfs_api.h: no such file or directory", and the error was located in the file SD.cpp. So I removed SD.cpp from the project. Keep iterating through this step one file at a time until you get a build with no errors. Take notes as you remove files (don't delete them) so you can add them back if you make a mistake. You may need to do some additional debugging here depending on what source files you added to your project. Be patient and expect a little trial-and-error as you review the Error List that is generated during the Rebuild. When you have a project that compiles without errors, celebrate with another beer (or two).
In your project source code, add the line:
Serial.println("Hello World!");
I put this in the while(1) loop of the blink-task function. This line of code will write to the serial port once every time the LED blinks. Since Serial.println is an Arduino function, you can be assured that at least this Arduino library is up and running. I believe you should be able to add more #includes (such as Wire.h) to your project and proceed in the same way (but wait on that for now).
Rebuild and upload to the ESP32. Open the serial port monitor (button near the top of the MSVS window, to the immediate right of the COM port pull-down) and verify that you are getting the "Hello World!" messages as the LED blinks.
Now, before you give me any grief about "dumping" all the library, header, and source files into my project folder, I realize this is not best practice. If you created a "bulk libraries" folder as I suggested, you should be able to organize your project better. This is left a simple step for the reader.
Since this solution relies on ESP32 hardware and VisualGDB, it won't work for everyone. However it allows you to migrate away from the "mysteries" that take place behind-the-scenes in the Arduino IDE, and allows you to create a foundation for better source control and project development. For a related discussion, see this link on sysprogs.com.
The String library is mostly free of platform-specific dependencies, so you could simply add WString.h and WString.cpp to your source files. You will likely have to do a little bit of porting (cleaning up some macros, I suspect), but there's no reason it shouldn't eventually build.
Many other libraries are going to be considerably more difficult to port over to your PC; anything that touches peripherals of the MCU are not going to port well.
Recently my project group bought a C/C++ codebase from a contractor which does not use Eclipse. Basically a big /src tree organized for building with Autotools, with a few top-level build scripts masking some of the Autotools complexity.
Developers on our project team have managed to set up the code in Eclipse (Luna) as an Autotools project...but what is currently causing grief, is that as we begin to work with this code, project CM is also moving to Jazz / RTC 5 (Formal process, not Agile) from ClearCase/ClearQuest.
None of us are clear about whether the code should go into the RTC repository in the form of a fully configured Eclipse project ready for developers to use.
My reading as a developer is that it must: if it doesn't, when I download the code to my repository workspace, I have to begin by bringing in new .project, .cproject, and .autotools files "behind the scenes" to get to a project that specifies the include paths I need, allows for C/C++ code analysis, and (hopefully) can be re-tweaked for Autotools building from within Eclipse. It also means when I deliver change sets back, it is likely to take a variety of error-prone workarounds to avoid delivering project-specific settings that aren't part of the codebase as conceived by CM. Right now, that's being held as close as possible to the contractor's delivered (non-Eclipse) package.
What I'm hoping, is that anyone can tell me if it is standard practice when using RTC with Eclipse, to set up one's code in RTC in the form of fully configured, ready-to-use Eclipse projects. The language used in the articles I'm finding suggests it, eg., talking about "Find and load Eclipse projects", but nothing I'm seeing makes this explicit.
is that anyone can tell me if it is standard practice when using RTC with Eclipse, to set up one's code in RTC in the form of fully configured, ready-to-use Eclipse projects.
That is a standard with any source control tool.
See "Shoul I keep my project files under version control?" or ".classpath and .project - check into version control or not?".
RTC simply suggest to create a .project just to reference the files of the component in the Eclipse workspace (as a convenience, to facilitate the file exploration of a given RTC component).
But that is separate from having a full-fledged .project, with many additional settings configured there.
I do not keep IDE specific files under version control.
You basically have an autotools project so what I do with that is put all the source autotool files (autogen.sh, configure.ac, Automake.am) under version control.
I also have a couple of scripts to setup autotools under different basic configurations (configure-debug.sh, configure-release.sh).
Then each developer simply runs the scripts which produce Makefiles.
Now they can use any IDE they wish based on the Makefiles. Each developer should be capable of working from a Makefile at least.
In eclipse I create an unmanaged "Makefile" style project and plug in the Makefiles that autotools produces.
But the project is not bound to eclipse, it is bound to any environment that runs autotools. Developers can use whatever IDE they prefer.
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).
Simply put:
In eclipse how do I run a shell/batch script when I build? I have an external tool that can be run by hand but I want to trigger it when the project is built. Using build variables in the script would be an added bonus.
Why I want this:
I work on multi-platform games for mobile. The teams in the company I'm at use X-Code, Visual Studio, and Eclipse (Momentics) for our games. We want to be able to pick up a phone and see overlay on-top of it with information such as who built it, when it was built, what branch and revision it's from, and what library versions are being used. I've done this with X-Code by running a script on build that dumps some of that information to the resource directory of my game that I can then parse at runtime. It's really simple and I'm up for alternate suggestions if you have them; keeping in mind it must work for the three IDE's our developers use.
Bonus Sugar:
In X-Code we can use build variables which would be super nice to have for eclipse as well. I use them to change to the active cocos2d-x repository and get a git log to tell us when the last commit to that repository was made and by who. If that isn't possible in eclipse I can figure something out.
Thanks in advance!
Add a custom builder to your project: open Project properties from the popup menu, on the builders page add a new Program. That will open a "External tool configuration" page.
There you can define a script to run, and also add parameters, where you can add Eclipse variables, such as ${workspace}, etc.
Be careful though: this will run every time when the incremental project builder runs, and the configuration is shared through version control (so beware of absolute paths).