Eclipse CDT: From Windows to Linux - c++

I have eclipse installed on windows and use cygwin to develop programs for linux. I compile using the cygwin toolchain and I also do my tests on cygwin.
Now I would like to compile my program also with the native linux toolchain and I also would like to debug it from the windows machine.
Is something possible with Indigo SR2? What is the best way to accomplish this?
I found this but then I would have two projects one for windows and one for linux. I would like to have just one project for both platforms to avoid syncrhonizing the sources back and forth.
Thanks.

I guess you want a cross platform development environment.
There are various tools for the job, but my choice would be CMake. Basically, you will write CMakelists.txt file instead of Eclipse .classpath and .project files, and generate those files with cmake executable. But in details, you will need to overcome some difficulties which are inherent in cross platform development.
I have successfully created more than one project with these tools, and they currently under a heavy load.

Related

Convert Unix Executable to Windows Executable

I compiled and ran a C++ program using Eclipse on my MacBook Pro. I now need to convert the Unix executable to a windows executable. How do I go about this? Specifally, how do I get this code to run on a Windows machine from the command prompt?
The only way you can get the unix executable to run on a Windows system is using a virtual machine (Something like VMWare or VirtualBox). This isn't REALLY running it on Windows, of course, it's setting up a UNIX system on Windows and running it on that UNIX system.
The executables (and the needed runtime environment) are vastly different between the two systems, you can't just run executables from one on the other.
Your only other option is to setup Eclipse on your Windows system and compile the application there.
You cannot "convert" an executable, you need to recompile for your target system. If you are using a GCC toolchain that is set up for Eclipse and there is no Mac specific code, it should be as easy as moving the project over, setting it up in Eclipse, and recompiling it. If that is too much of a hassle, you can consider setting up a Makefile and using MingW or Cygwin, or even Visual Studio if you'd like. If there is Mac specific code, then you need to look up the appropriate Windows documentation, or use something cross-platform like GTK+ or Qt.

How to compile C++ application for Unix/Linux in Windows

I have an application written in C++ using wxWidgets. How can I compile it for Linux and Unix os like Debian, FreeBSD, CentOS, in Windows?
Thanks!
Not entirely sure if I understood the question, but I think you are asking if you can compile an application for linux using a compiler in the windows environment.
My short answer: No, but.
The but: You may be able to use Cygwin in windows, however I think there is an easier way. If you are uncomfortable with setting up your computer to have multiple partitions and installing linux on at least one of these partitions, you can use VirtualBox, VMWare, or similar virtualization software to "install" linux on your windows machine. From there you can set up build environments and such. As for how, I would leave your windows build as is, but then in create a Makefile for Linux (or use CMake to replace both your windows-specific builder (the vsproj if using visual studio, etc) and linux-specific builder (make)) so that your source will compile both on windows and linux without having to modify the actual code or project.
i would recommend to use CMake as build system

Compile A MSVC++2010 Project So It Can Run On Ubuntu

I have a MSVC++ 2010 project. All the libraries it's using are cross platform (SDL, OpenGL and FLTK).
Obviously, all I have to do right now is press the debug button and it will compile a nice old .exe for me which can now run on Windows, as long as the DLL files are with it.
I had thought before that if you use cross platform libraries, then the generated .exe would run fine on Ubuntu too. I recently found out that this is not possible, and that the program must be compiled in a special way to run on a certain platform.
Is it possible to compile my project in this magical way with MSVC++ 2010 so that it can run on a Ubuntu computer? If so, then could you please answer my question with some clear steps as to what I should do to compile it this way, keeping in mind I'm new to how all this cross platform stuff works?
EDIT:
If I cannot compile a MSVC++ 2010 project for Ubuntu, is there an IDE I could use that could compile the project for both Windows and Ubuntu?
Thanks.
I suggest you use QT. http://qt.digia.com/
It's probably the best cross platform IDE that can let you compile for Windows, Mac and Linux(ubuntu) systems.
Nope, not possible. While the binary code corresponding to the program can be portable, that's not enough. Executable formats on various file systems are different and not compatible. The executable format is essentially a packaging of the binary data and wrapping it with a header that the target file system understands. In order to produce executables for Ubuntu, the linker must support it. MSVC++ doesn't support Linux formats.

Multiplatform IDE

I recently realized I'm making it unnecessarily hard on myself to use 4 different IDEs, for every combination of (develop on Windows, develop on Linux)x(program runs on ARM, program runs on local x86 PC).
Currently, every time I switch between an ARM project and a x86 project (often a console app to pre-calculate lookup tables for the ARM project), I switch between IDEs.
If I already have YAGARTO installed on my Windows PC, what's the best way to set up (another?) Eclipse CDT to compile C++ code natively for my PC?
Is it better to somehow install 2 copies of Eclipse CDT, one set up to create ARM binaries, the other set up to create x86 binaries? How?
Is it better to install Eclipse CDT once, then somehow tell it to compile this project into an ARM binary, and that project into a x86 console app? How?
Is there some other IDE that understands that different projects run on different CPUs? What?
( Multiplatform C++ cross-compiler talks about building multiple cross-compilers. But I'm missing the next step: Once I have a few cross-compilers built, how do I hook an IDE up to them?)
You can switch toolchain configurations within Eclipse based on targets or projects. There's no need to switch IDEs, it's just a matter of associating toolchains correctly.
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_build_toolchain.htm
http://www.frozentux.net/2008/10/switching-gnu-toolchains-in-eclipse-the-easy-way/
http://eclipsebook.in/c-cpp-development/building-code/build-eclipse-managed/

Building C++ on both Windows and Linux

I'm involved in C++ project targeted for Windows and Linux (RHEL) platforms. Till now the development was purely done on Visual Studio 2008. For Linux compilation we used 3rd party Visual Studio plugin, which read VS solution/perojects files and remotely compiled on Linux machine.
Recently the decision was to abandon the 3rd party plugin.
Now my big concern is a build system. I was looking around for cross platform build tools. This way I don't need to maintain two set of build files (e.g. vcproj/solution for Windows and make files for Linux).
I found the following candidates:
a. Scons
b. cmake
What do you think about the tools for cross-platfrom development?
Yet another point that bothers me is that Visual Studio (+ Visual Assist) will loose a lot functionality without vcproj files - how you handle the issue with the tools?
Thanks
Dima
PS 1: Something that I like about Scons is that it
(a) uses python and hence it's flexible, while cmake uses propriety language (I understand that it's not a winner feature for a build-system) (b) self contained (no need to generate makefiles on Linux as with cmake).
So why not Scons? Why in your projects the decision was to use cmake?
CMake will allow you to still use Visual Studio solutions and project files. Cmake doesn't build the source code itself, rather it generated build-files for you. For Linux this can be Code::Blocks, KDevelop or plain makefiles or still other more esoteric choices . For Windows it can be among others Visual Studio project files and still others for MacOS.
So Visual Studio solutions and projects are created from your CMakeLists.txt. This works for big projects just fine. E.g. current Ogre3d uses CMake for all platforms (Windows, Linux, MacOS and IPhone) and it works really well.
I don't know much about scons in that regard though, I only used to build one library and only in Linux. So I can't compare these two on fair ground. But for our multi-platform projects CMake is strong enough.
I haven't used Scons before, so can't say how that works, but CMake works pretty well.
It works by producing the build files needed for the platform you're targeting.
When used to target VC++, it produces solution and project files so from VS, it appears as if they were native VS projects. The only difference is, of course, that if you edit the project or solution directly through VS, the changes will be erased the next time you run CMake, as it overwrites your project/solution files.
So any changes have to be made to the CMake files instead.
We have a big number of core libraries and applications based on those libraries. We maintain a Makefile based build system on Linux and on Windows using the Visual Studio solution for each project or library.
We find it works well for our needs, each library or app is developed either on linux or windows with cross compilation in mind (e.g. don't use platform specific api's). We use boost for stuff like file paths, threads and so on. In specific cases we use templates/#defines to select platform specific solution (for example events). When is ready we move to the other system (linux or windows), recompile, fix warnings/errors and test.
Instead of spending time figuring out tools that can cross compile on both platforms we use system that is best for each platform and spend time fixing specific issues and making the software better.
We have GUI apps only on Windows atm. so there's no GUI to cross compile. Most of our development that is shared between Windows and Linux is server side networking (sockets, TCP/IP, UDP ...) and then client side tools on Linux and GUI apps on Windows.
Using with perforce for source code version management we find in quite many cases that the Linux Makefile system is much more flexible for what we need then Windows VS. Especially for using multiple workspaces (views of source code versions) where we need to point to common directories and so on. On Linux this can be done automatically running a script to update environment variables, on Visual Studio referencing environment variables is very inflexible because it's hard to update automatically between views/branches.
Re sync question:
I assume you are asking how to make sure that the two build systems get synchronized between linux and windows. We are actually using Hudson on Linux and CruiseControl on Windows (we had windows first with cruise control, when I went to setup linux version I figured Hudson is better so now we have mixed environment). Our systems are running all the time. When something is updated it is tested and released (either windows or linux version) so you would know right away if it does not work. During testing we make sure all the latest features are there and fully functional. I guess that's it, no dark magic involved.
Oh you mean build scripts ... Each application has it's own solution, in solution you setup up dependencies. On Linux side I have a makefile for each project and a build script in project directory that takes care of all dependencies, this mostly means build core libraries and couple of specific frameworks required for given app. As you can see this is different for each platform, it is easy to add line to build script that changes to directory and makes required project.
It helps to have projects setup in consistent way.
On Windows you open project and add dependency project. Again no magic involved. I see this kind of tasks as development related, for example you added new functionality to a project and have to link in the frameworks and headers. So from my point of view there is no reason to automate these - as they are part of what developers do when they implement features.
Another options is premake. It's like cmake in that it generates solutions from definition files. It's open source and the latest version is very highly customizable using Lua scripting. We were able to add custom platform support without too much trouble. For your situation it has support for both Visual Studio and GNU makefiles standard.
See Premake 4.0 Homepage
CruiseControl is a good choice for continuous integration. We have it running on Linux using Mono with success.
Here is an article about the decision made by KDE developers to choose CMake over SCons. However I've to point that this article is almost three years old, so scons should have improved.
Here is comparison of SCons with other building tools.
Had to do this a lot in the past. What we did is use gnu make for virtually everything including windows at times.
You can use the project files under windows if you prefer and use gnu make for Linux.
There isn't really a nice way to write cross platform makefiles because the target file will
be different among other things (and pathname issues, \ vs / etc). In general, you'll probably be tweaking the code across the various platforms to take subtle differences into account, so a tweak to a make file and checking on the other platforms would have to happen
anyway.
Many OS projects maintain Makefiles for different platforms such as zlib where they are named like Makefile.win, Makefile.linux etc. You could follow their lead.