IDE use a VM compiler? - c++11

I'm starting to work on my master thesis at the moment and I have a (maybe) specific question...
I want to stay on windows OS and run a Linux VM via VirtualBox combined with Vagrant. No Problem. I like the feature to reset the VM via vagrant easily.
The next target is using features like auto-completing or similar while developing in C++. This would help me to work with unknown includes/libraries.
Is it possible to access the filesystem/compiler of the VM while using an IDE (like clion) installed on windows? Without explicit loading of the gui und running the IDE on it? Kinda like working with cygwin? I don't want to use cygwin because it doesn't support c++11 standard (or is there a way???)
Maybe you know an alternative way. I would be glad for all hints solving my problem.

I don't know much about cygwin, though I would be surprised if they cannot get recent versions of gcc. But for certain, you can use MSYS2 to get very recent versions of gcc and many other linux packages, which will support C++11.
It's a matter of opinion how best to do cross-platform development, but an alternative worth mentioning is to use cmake for your project. When you want to code in windows, it can make MSVC 2015 project files for you -- when you want to compile in linux, it can find the dependencies and generate a makefile for you to use. IIUC, cmake is the most widely used cross-platform build system right now, besides gnu make itself. (I'm pretty sure it's more popular than "autotools" nowadays, and its definitely more popular than scons.) The advantage is that you avoid the need to maintain multiple platform-specific project files that essentially say the same thing with different formatting.

Related

Set up a development environment on Linux targeting Linux and Windows

For a university course I have to write a http server which is supposed to run on both Linux and Windows.
I have got a humble Linux machine which I don't think can handle any kind of heavy virtual environment, neither I'm willing to go through the hassle of installing it.
This is the first project of mine complex enough (I estimate ~1.5 months to develop) to require an environment sufficiently comfortable to alternate rapidly between short coding and testing sessions (the latter on both platforms, of course).
So, I was wondering what could be the best set up for this situation. I think testing it on Wine would be ok (it is not a real-world thing, after all), and I installed MinGW for the Windows-targeting part.
Basically, a simple well-written makefile could solve my problem... It should build both the Linux and Windows binaries and place them in the respective folders (the Windows one in the Wine sub-tree) and I'm all done! But I feel very inexperienced in this thing and I really don't know where to start. Maybe the make manual, ahah!:)
Thoughts, suggestions, anything I didn't think/know!
Thank you!
(PS. I'm planning to use emacs as editor, or maybe learn vim. Unless eclipse provide some kind of skynet-like plugin that entirely solve this problem...:)
You're on the right track. It's not that complicated, really, thanks to MinGW. You basically need two things:
The code has to be portable across the OSes. MinGW has some POSIX support, but you'll probably need to either use Cygwin in order to be able to use the POSIX interface or have your own compatibility layer for interfacing with the OS. I'd probably go for Cygwin as then you can code only against POSIX and won't have to test and debug your compatibility layer. Also, make sure you won't use any external libraries that are OS specific. Non-portable code often results in a compile error, but make sure you test the application thoroughly anyway.
The toolchains for targeting Linux and Windows. You already have them, you just need to use them correctly. Normally you'd use a variable like $(CROSS_COMPILE) as a prefix when calling the toolchain during cross compilation. So when compiling for Linux, you call gcc, ld, etc. (having the CROSS_COMPILE variable empty), and when compiling for Windows you call e.g. i486-mingw32-gcc, i486-mingw32-ld etc., i.e. CROSS_COMPILE=i486-mingw32-. Or just just define CC, LD etc. depending on the target.
I wrote a small game on Linux and made it run on Windows as well. If you browse the code, you can see the code has next to no #ifdef jungle (basically just some extra debugging features enabled for Linux), and the Makefile is simple as well, with no complicated handling for cross-compilation, just the possibility to override CC etc. like it should be. As lots of important open source software is written this way (especially software that's used by the desktop and embedded devices), you should also be able to find lots of other examples on how to set up the build environment correctly.
As for testing the application on Windows, I think the best option is if you can find a real Windows machine somehow. If you do everything correctly, it should run the same as on Linux and you won't need to continuously test your application on both OSes. If testing on a Windows machine is not possible, a VM would be the next best choice, though it would probably be more difficult to set it up. Wine is a good backup plan, but I don't think you can be sure your application works well on Windows if you only tested it on Wine.

Compiling Visual C++ code in linux

I have written a code in visual c++ , which is a sort of GUI used in virtual com PORT connection. However , i need to run that code in linux so that i can make it an open source. Since , visual c++ doesn't work in linux, I need to find out some alternatives.
So, please me what all alternatives I have
Thanks for your valuable time..!!
i need to run that code in linux so that i can make it an open source.
No, you can license code as open source without it running on linux.
If you simply want your code to run under linux you need to learn how to port from VC++ to Linux/GNU. It's not simply a matter of re compiling it.
See the following URL for advice and google search for more if required: http://www.johndcook.com/blog/2008/05/29/porting-visual-c-code-to-linuxgcc/
In my experience you can get a looooong way with
http://www.winehq.org/docs/winelib-guide/winelib-toolkit
winemaker (doing things as making all your includes case-sensitive correct on Linux)
winegcc (linking to the winelib runtime libs so you can have _WinMain and stuff like that just work)
Of course there are libraries that simply don't exist. Also, installing an SDK can be daunting; winetricks.sh is very helpful in that department. Also, you can consider 'XCOPY' deploying the SDK into your linux build tree and working with that;
This has successfully let me cross compile MSVC projects linked with 3rd party windows libraries in the past. Note minor incompatibilities due to having slightly different linkage semantics with gcc/GNU ld by default; expect this to affect areas like RTTI and exceptions thrown across DLL boundaries).
YMMV
Edit I want to confirm the fact that you can have perfectly valid opensource code for windows only, and you can build it using Visual Studio too. If you want to be nice to your (prospective) contributors, make sure you only depend on Visual Studio Express C++ (not MFC, e.g.) but hey, that's really up to you!
which is a sort of GUI used in virtual com PORT connection
This will be probably hardly portable (because of the BIG differences how virtual ports and GUI are handled in linux and windows - unless you used some cross-platform library already in Windows).
You can release your code as OpenSource for Windows only.

GCC on Windows OS

I was wondering is there a free Windows version of GCC.
I know there is minigw and something else but I don't know how to use them.
Sorry if this should be on SU.
The main choices are either MinGW or CygWin.
CygWin is a more complete UNIX-like environment than MinGW as it offers quite a lot of tools over and above development stuff. Even to the point of a full X-Windows server so you can develop software that'll run on both UNIX-like systems and Windows.
The installer is good but I would suggest installing everything even if you think you don't need it. Disk space is cheap and I've had problems in the past trying to get stuff going on partial installs (whether 1.7, or even earlier, fixes this, I don't know - I always do full installs).
However, it relies on the CygWin UNIX emulation DLL which, if I remember rightly, has restrictions for non-free software.
MinGW is more concentrated on the development tools. It generates native Windows applications rather than running under a emulation DLL like CygWin.
It used to be difficult to install with having to do MinGW, MSYS and others separately but it's come a long since then and has an easy graphical installer.
I believe it can do graphical applications using native Windows calls rather than via X-Windows, since it just links to the normal Windows runtimes.
If you want to know how to use either of them, you really have to look through the docs found at those links I provided - check the Documentation link on the left for MinGW (particularly Getting started) or the CygWin FAQ.
As for GUIs for development, I've never used one for CygWin - I'm old enough that I remember mark sense cards so I'm not scared of the command line interface :-).
I used Eclipse with CDT running over MinGW and wasn't that impressed although admittedly that was an early version. Don't get me wrong Eclipse is a brilliant tool and we use it for both Java and Linux/C development, I just had a lot of troubles with Eclipse/CDT under Windows.
Code::Blocks, on the other hand, was absolutely brilliant but you should check them all out to see which one suits you best. As I said, the last time I looked was about five years ago, an eternity in the IT world.
I am a bit late, but since the question may still arise...
gcc for Windows (including Ada, C, C++ and Fortran compilers) can be obtained from MinGW-builds on SourceForge: http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/
As of august 2013, there are 32 and 64 bits versions of gcc-4.8.1.

Techniques to provide a shared build environment on Windows and Unix

I'm certain this has been asked before, with with nearly 900k questions, it's hard to find things :)
We are starting a project where we want our C++ and Python to run both under a Unix environment but also under Windows. We want to make our project easy to contribute to as developers, and so we wish to have what each side feels is "natural."
In this case, under Unix, it's automake/autoconf/etc. Under Windows, anything but visual studio project files seems like a mistake. This is mostly because we want windows-native hackers to have a way to easily develop in their natural environment.
How are people doing this sort of thing today? Are Windows coders comfortable in a non-GUI world, so we are trying too hard?
Another goal is that we need automated testing of our project, ideally using the same test code (google-test) on all platforms, etc. This may be matter for another question, though.
Multi-platform development can be a tricky situation. Here are some things we do to ease the process:
Source Control (this one is obvious, a solid code-base that works with both Windows and Linux, we use SubVersion)
Create standards (All of our Makefiles look identical and are easy to implement as are our .sln files for Visual Studio)
Build the application on all platforms, frequently
Be aware of cross library use like QT and any quirks that might contain between Windows and Linux
Sometimes you can't avoid it: #ifndef's to execute some code specific to a platform
We develop in Windows, Sun and Linux (RedHat) with multiple applications both visual and command line based. I hope that helps!

Setting up an emacs environment in windows?

I am currently constrained to a windows dev box and I want to migrate my projects from eclipse to emacs.
What are some good references on setting up an emacs dev environment for windows? Anything that could assist in migrating from eclipse as well would be appreciated.
If you're used to windows behaviors (e.g. ctrl-c is copy, etc.), a good (customized) version of emacs for windows is the 'EmacsW32' package.
If you're looking at migrating away from eclipse, I assume that you probably want java support. For this you will want to get the JDEE package, also. Unfortunately, it's non-trivial to deploy on windows, as it depends on other packages (and requires cygwin or msys (pseudo-unix environments for windows) in order to install).
You may also want to install additional modes to support e.g. SCM systems, etc. A good source of information for this is the EmacsWiki. There's a significant amount of material there about emacs on windows, although some of it is out of date....
Sure, just download a prebuilt version and use it.
For example, as I use R a lot with the wonderful Emacs ESS mode, the prebuilt version by Vincent Goulet is really useful as it contains Emacs, ESS, Auctex (for LaTeX) and more.
Other prebuilds exist for Cygwin, MinGW, or plain old Windows.
Eclipse is pretty good on Windows; I'm a big user of emacs but for Java development I spend most of my time in Eclipse.
Regarding general use of emacs on windows I highly recommend you install GnuWin32, as it is much faster than Cygwin and integrates very well. Also see my blog post on Visual Studio tricks in emacs and this one on tags.
I'll assume you are doing Java development for the most part and that you would prefer not to be using Windows. This is a situation I find myself in from time to time. My preferences are to use a Linux machine (virutal or real) in addition to the Windows machine. Emacs just works better in a real Unix environment. And then use both Emacs and Eclipse where each is stronger. Emacs for editing, mail, planning, "thinking" type stuff and Eclipse for debugging, refactoring, some error fixing. Fortunately both Emacs and Eclipse make it easy to use both simultaneously.
I generally use EmacsW32 on a new box - it's a good option at least initially. I'd also recommend checking out the emacs starter kits which hook up to ELPA (http://tromey.com/elpa/), which allows you to get a usable setup pretty quickly.
Install Cygwin.
In your .emacs, load these two files, in this order:
http://www.emacswiki.org/emacs/download/cygwin-mount.el
http://www.emacswiki.org/emacs/download/setup-cygwin.el

Resources