Starting From Windows
At this point, we have a project in Eclipse under Windows that will build with Visual Studio compiler, there are no errors or warnings in the IDE, and code completion works. The next step is to get the source onto a Linux machine and configure a Linux build. I'm using SVN to transfer the project between machines but you can copy the project to your Linux system instead.
Once the source is on your Linux system, open the project in Eclipse. You will receive errors and warnings about missing include files and unresolved symbols, and the application won't build. The IDE is using Windows paths and build tools, which are obviously not valid under Linux. The first thing we need to do is create debug and release builds for Linux that point to the correct compiler.
right-click on the sort_win project and select Properties. Expand C/C++ Build and click on Settings. Select the Manage Configurations... button, and select the New... button, in the Manage Configurations window. Under name, enter Debug-Linux, select the Import predefined radio button, and select Executable→Linux GCC→Debug. Select OK. Repeat this process substituting Release for Debug to create a Release build (see Figure 5).
After creating the new build configurations, enable Debug-Linux: right-click on the project, browse to Build Configurations→Set Active→Debug-Linux. The IDE will now use GCC to build the application, but the code completion index is incorrect. When building applications across platforms, each platform needs its own index. The IDE has a setting to use the active configuration for creating the index.
To enable this feature, right-click on the project and select Properties. Expand C/C++ General and select Indexer. Check the Enable Project Specific Settings at the top of the window, and select the Use Active Build Configuration at the bottom of the window. Select OK. If the errors don't disappear right a way, rebuild the index as described previously (Figure 6).
Starting from Linux
Creating a project in Linux and transferring to Windows is a nearly identical process. Select File→New→C++ Project. Name the project sort_lin, select Empty Project under project type, and select Linux GCC under Toolchains (Figure 7). Select Finish.
Next, add a main.cpp source file with the same source that was used in the Windows program. Once the project is complete, transfer it to your windows machine, launch Eclipse from the Visual Studio command prompt and open the project. You should notice that we have the same problem that we experienced previously when transferring from Windows to Linux: The IDE shows a bunch of errors and the project won't build. We need to add debug and release build configurations for Windows. Follow the previous instructions for adding new build configurations under Linux, but use the Executable→Microsoft Visual C++ →[Debug | Release] option. Next, add the path ${VCInstallDir}\include to both of the new build configurations.
If you activate the windows configurations, the project will build, but the IDE will still show a bunch of errors and warnings. As we did in Linux, we need to enable project-specific indexer settings. Follow the previous instructions to enable the settings and rebuild the index if needed. Make sure to add the Visual Studio path as mentioned previously before enabling project-specific indexer settings. A few times, I misspelled the directory and it defaulted back to use a fixed-build configuration. Double-check your settings if the errors don't disappear after rebuilding the index.



