Techniques to provide a shared build environment on Windows and Unix - visual-studio

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!

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.

Quick and simple programming language

Is there someone that can suggest me a programming language that allows you to write quickly GUI programs (on windows platform)?
P.S. I am interested on only languages that do not rely on virtual machines and then have a compiler that produces executable code directly on the machine
I would go with AutoIT, it's a very easy to learn windows scripting language with tons of functionalities: http://www.autoitscript.com/autoit3/index.shtml
I'm using it to automate some tasks, but it can do way more than that.
EDIT
Just to make things a little bit clearer for everybody:
You can create new applications using AutoIT and the Aut2Exe compiler provided. The .exe files created are stand-alone, thus require no other files but the files that you might need in your app. Everything is free and the AutoIT scripting language has a BASIC-like syntax.
The GUI that you'll use are standard Windows controls. Among the functionalities you have the possibility to automate keystrokes/mouse movements, call the Windows API and external .dlls, manipulate windows and processes and through user created libraries (called UDFs) you can even acces local databases, manage networking tasks, encryption, archiving and many more.
All I can say is that it's worth take a look and the first app I built with AutoIT was done in roughly 8 hours since I started learning. It took a folder as the source and copied everything in a chosen directory, copying files in folders named as the date when the files were created. So the destination directory would have a series of subfolders like:
11.11.2010
whatever.txt
whatever.png
12.11.2010
archive.zip
and so on. Just 8 hours and got me rid of a lot of effort ordering the files myself.
Any .NET will probably be what you're after.
Start with VB.NET which is now called Visual Basic CCYY eg (Visual Basic 2005, Visual Basic 2008, Visual Basic 2010).
If you want something not using .NET framework, you might as well go back to older version of VB and if you want something compilable that'd be like C++ with their MFC (Microsoft Foundation Class).
You need to give more info on the type of gui and what you're using it for. This could be accomplished with Microsoft Access forms and VBA, or you could make an HTML Application (.hta).
I'll put in a vote for Delphi. You can easily write applications by dragging and dropping components on to a form and doing minimal coding in Pascal, which isn't hard to learn. Later, if you decide to go deeper, you can do pretty much whatever you want. And it compiles to native executable code.
Is an executable bundler, that combines the script with the framework/interpreter, good enough?
If so, you might look at Tcl/Tk or Lua.
http://www.powerbasic.com/
http://www.powerbasic.com/aboutpb.asp
Seems like it has a RAD GUI and of course it's BASIC, plus it compiles down to .exe (as I understand it.) Might be worth checking out.
A 'quick and simple' language will only allow you to do 'quick and simple' things - and for those, having a VM or not wont make much of a difference to you.
For quick and simple & native code, about all I can think of is RealBasic. Its cross platform Windows/Mac/Linux. I find their IDE to be difficult to work with due to its inflexibility and the help system last I looked wasnt that great, but the underlying language isnt bad and does compile to native code. So it might do the trick for you.

Completely Stand-alone gui-application

Which programming language and tools can i use, to develope a complete stand-alone gui-application? This application will be burned on a cd and should run on every windows-pc without any installations.
Questions like what your application and what your capabilities are need to be considered.
There are many solutions to your problem. From 'Visual Studio Ultimate' to a HTML file which contains javascript.
Win32 API.. a similar question was asked today...
Use Visual Studio (you can use express edition) and build whatever you like.
This is the most powerful language, yet development time is very very slow, but the results are:
a. independent.
b. if you a good programmer - small and fast.
one thing - you got to know what you're doing when programming win32...
one Petzold book will get you where you want to go.
similar question
Well, if you really have the time and don't need to deploy on 16-bit Windows, you could always write in Win32 assembly -see MASM32 and Iczelion's Win32 tutorials. There's even a IDE for Win32 ASM -WinAsm Studio :)
The only dependencies you'll need are the Windows system DLLs which are already there on every Win32 system.
However, if you need to build something quick, something like Visual Basic 6 will do nicely - it only needs the VB6 runtime by default (1 ~ 2 MB) and that definitely fits into a CD together with your VB6 EXE.
I'd go for C++ with MFC. Reasonable development times and with static linking it could all be one standalone exe file.
If you are just looking to make one of those interactive splash screens, might want to look into Demoshield. I know its old and not supported any longer, but can be of real use for something great looking.
http://www.componentsource.com/products/509937/12838/index.html
You can find copies of it free by google-ing it. Don't think the company is around any longer so not sure if this is legit or not.
But not the right choice if you need to do some serious programming stuff.
Delphi also may be a good choice.

Development Environment in Windows [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What are your recommendations for setting up a development environment in Windows, especially when not using an IDE. I am attempting to familiarize myself with Windows, and I feel a bit lost. What do developers commonly work on, especially when developing in multiple languages (e.g. Java, Python, C) in the same time.
So far, I have been a hardline using Mac+Linux environments where I love my command line a lot. I pretty much run all my compilations, testing, code repository commands in the terminal and have multiple terminals all the time. Terminal features (e.g. integrated bash completion, easy copy&paste, easy to setup environment variables) and package management tools (e.g. apt-get, port, fink) are quite handy. I dislike hunting down different websites to install their latest binary build.
Coming back to my question. My question is two fold:
What's commonly used? Do developers on Windows commonly use command line, or just be satisfied with an IDE?
For comers from Linux/Mac world: what do you recommend to get up to speed?
NOTE: I realize that a lot of Windows developers haven't used Linux, so they may not know what I'm talking about when it comes to Linux environment.
It's almost unheard of to not use an IDE for Windows development.
I started programming in the early 80's so grew up on the command line, but nothing beats a modern IDE for productivity.
By far the most common choice is Visual Studio, though I have also used #develop (open source) and find it a fine platform to get up to speed with.
I have used Eclipse extensively (on Linux and Windows) and find Visual Studio to be easier to use. I especially miss options for debugging under windows such as moving the instruction pointer around during debug and change-and-continue (change the code, within limits, while debugging, move the instruction pointer back if necessary, and keep debugging).
If you have used Eclipse, Visual Studio or #develop will not be that hard to get used to.
I tend to install cygwin, which is a unix emulation layer and includes many of the standard unix utilities (grep, awk, sed, etc). You can use bash or any other unix shell with cygwin to basically give yourself a unix environment on windows.
There are some downsides, paths are a good example. Windows programs expect windows paths while the unix tools expect unix paths. You can convert between the two using the cygpath program, but sometimes its tricky to know when to use it.
Another thing I do fairly often is create a bunch of batch files that load different programs onto my path. This allows me to have different version of say java installed and I can pick the version I want to use for any given shell session. I link a bunch of these together so that I have a full environment for the program I'm working on. For example, if I require java 1.5, maven, subversion then I would have a batch file to load each into the environment, then have a master file that loads all of them for a standard environment.
This approach gives a lot of flexibility and is really easy to maintain and work with different environment simultaneously.
Most windows developers that develop on the microsoft stack of products probably use Visual Studio. For windows development without Visual Studio, SharpDevelop is the current most popular alternative.
However if you are looking for a user experience more similar to linux you can always use windows command prompt and all of the command prompt compilers still exist. Just like with linux you'll have to modify your environmental variables to make everything work you you'd like it to.
If that still isn't close enough to the feel on linux, you can try out Cygwin.
Many of your common utilities from linux like gdb do have windows builds as well.
And of course there is the Eclipse IDE that is used for many languages, by many people, on multiple platforms. It is very extendable.
Some other tools you may be missing:
GCC - Available Via Cygwin
MS Build can give you similar functionality to what you had with make (I'm not sure if nmake is still used/supported)
Vi/Vim
Grep
SysInternals will have lots of various file/process monitoring utilities to hopefully adequately replace what you miss being able to simply get from /proc
Wireshark(or ethereal) to replace well... wireshark/ethereal/
Tail is available in the Windows Resource Kit
Emacs
Hopefully that covers most of your basic tasks.
Microsoft now has a real shell for Windows: Windows PowerShell.
In addition to Cygwin, there are ports for a lot of the GNU utilities and toolchain to Windows. GnuWin32 seems to be a more up-to-date version than UnixUtils. MSYS is essentially a port of BASH to Windows, but it's fairly useless without the MinGW userland.
C++ / .NET Development: Visual Studio 2008
Java / PHP Development: Eclipse IDE, which also supports C/C++.
For a non-IDE solution, Notepad++ is a very good code highlighter that supports many languages.
Simply install cygwin. The quality has improved dramatically in recent years. I'm currently running cygwin x64 on Vista, and it's great.
One thing to especially take note of in cygwin is your path. Most troubleshooting with scripts and installed software should begin there.
The other tip I'd give is to use the rxvt terminal over the standard issue cygwin terminal. It might be installed by default nowadays, but check to make sure.
Visual Studio for .net/C++ (even the express editions are useful)
The sysinternals tools rock, especially Procmon and process explorer.
If you do native/C++ work knowing windbg can be helpful
Notepad++ and gvim are my preferred editors
For doing command line/shell stuff I often use python to write short scripts (for anything but the simplest batch file)
If you are familiar with .net then learning powershell isn't much of a stretch and there is a ton of functionality available

Adding support of Windows to POSIX project... How painful? Is it worth the effort?

I'm trying/thinking of making CppCMS - C++ Web Framework project little bit more cross platform.
Today I can easily support Linux, OpenSolaris, FreeBSD and even Cygwin. But when it comes to Native Windows it becomes really painful:
The overview of the situation:
I'm POSIX/Linux developer and I'm barely familiar with Native Windows development tools like Visual Studio and Win32 API. However I do some work for this platform so I understand the limitations and the fact that Windows is totally different world.
This is web project that uses APIs that popular in Unix world, like: CGI, FastCGI and SCGI that implemented in most UNIX web servers; but I understand that I would not be able to use it with IIS because it does not support FastCGI over TCP/IP (only Windows pipes).
So even when it would work it would probably run only with Windows port of Apache.
I relay heavily on POSIX API:
Pref-forking allows be keep high survivability in case of crashing (not supported under windows) so this feature would be missing.
I use some file-locking facilities (but I can probably give them up without forking)
I have intensive use of native pthreads, even I can replace them with Boost.Thread
I probably would never be able to support Visual Studio (maybe 2010 with C++0x support), because I relay on C++0x decltype/auto feature or typeof/__typeof__ extension that is supported by most compilers I worked with: gcc, intel, sun studio. (To be honest: I can work without them but it makes the life much easier to framework user.
I relay heavily on autotools and I can't replace them with CMake, bjam or friends, because when it comes to support of internationalization, cross copiling, package management, they just does not give me a solution.
There are many annoying points like missing gmtime_r, or localtime_r under windows and many others that just require from me to rewrite them or replace them with 3rd part libraries.
There are still many "UNIX like" libraries that ported to Win32 like: iconv, gcrypt and some others that are barely ported like libdbi that have many limitations on windows.
Bottom line:
There is lots of non-trivial work to do, and even when it would be complete, it would probably work only with MingW tools and not "native" tools that Windows programmers are
familiar with.
So, my questions are:
Does such MingW port worth an effort? Would this help to build bigger community?
Does anybody have experience on how painful porting big projects from POSIX environment to
Win32 API is?
Would it be useful for Windows developers at all?
Edit:
It is also important for me to understand, how many of windows developers prefer to use
Open source development tools, MingW over Microsoft development solutions like VS.
Edit #2: Clearification about "native" windows solusions and IIS.
In fact, running framework with IIS is really hard problem. I explain:
The project relates to standard web server API as FastCGI or SCGI that allows to accept many requests over sinlge socket. Thus, on application side, I accept new request proceed it and returns the answer. Sometimes several threads process several requests.
Thus, implementing one or two standard protocols I open communication with any existing server: Apache, lighttpd, nginx, cherokee... or any other servers; with small exception of IIS
IIS has implementation of FastCGI, but... It supports only 1 connection per local process only that controlled by web server...
So... there is absolutely no standard way to connect my application to IIS.
Please note, I implement standard Web server API, I do not implement Neither IIS proprietary ISAPI nor Apache proprietary API, even the second is more important as for targeting UNIX world.
So, just Windows IIS Web world is just not really ready for cooperation for such project, so if anybody would use it under Windows it would use it with more open web servers.
You should base your decision on user demand. Have users ever requested using the framework on Windows? If so, did they explain why they wanted to use Windows (e.g. what additional constraints they had, what webserver they wanted to use, etc.)?
Typically, Windows users do expect that things work the Windows way. That means Visual Studio support, IIS support, MSI installer, and so on. If something still feels like being Unix, I would rather use Unix proper, instead of fighting with a half-working port.
As a windows client app developer it sort of hurts me that the development environment division currently is essentially Win32 and everything else and that they are mostly incompatible. That's why I'm preparing to move to MinGW for my personal windows app projects and to try to make them cross-platform.
I would suggest gradually moving to more cross-platform libraries like, as you suggested, refactoring pthreads to boost::thread, or going from fork() to multi-process with IPC, probably also using boost's facilities. Date/time stuff can be dealt with Boost libs as well. As for database support, there are
Microsoft compiler support is not that important I think, as MinGW provides a decent build environment with all the IDEs that support it, Eclipse CDT and Dev-C++ being among the most popular. But if you are going to make your project msvc-compatible, make sure users will be able to use Express editions of Visual Studio 2010 (as soon as thay come out) - that way no one will have to fork out for a Visual Studio 2010 (upgrade) just to use your project and there will be no problem for you to require the latest in Microsoft technology.
Most likely you won't avoid some amount of ifdefs for a code base of your project's size, but surely the effort might be worth it, if not only for gaining valuable experience and expanding the community with a few new happy and grateful members.
Your saying that you can support Cygwin quite easily reminds me that I've seen commercial Windows software that simply bundled in cygwin1.dll to support some originally-Unix code. If adding cygwin1.dll to your installer is all it takes, try it out.
I think you only have to look at the questions asked on SO to work out that MinGW users on Windows (of which I am one) are in a minority in the development community - the vast majority of Windows developers are using MS tools. Anyway, the compiler is only half (or less) of the issue - if your architecture depends on forking lots of processes, using MinGW is not going to help you. My advice is, if you really want to do cross platform development:
look at how Apache do it
consider using the Apache libraries as your base
don't use very new or compiler-specific language features
use multi-threading rather than multi-process
Does such MingW port worth an effort? Would this help to build bigger community?
I am still working myself on this issue with my own large POSIX project and my conclusion is that if you need to later interface with Microsoft products, then its worth while, however then I would only use MingW if project is medium small, if it is very large, then I would go all the way with MSDN Microsoft development tools - Huge amount of help will be available there - however it will cost
Does anybody have experience on how painful porting big projects from POSIX environment to Win32 API is?
sofar my own conversion of my POSIX project have been constantly put on hold, because of the amount of time each issue takes to handle is enormous - not finished converting yet - If I ever will be
Would it be useful for Windows developers at all?
Sure working inside the Microsoft IDE using tools from MSDN will definately decrease development time, however it will increase your dependence on Microsoft libraries - something you need to decide from beginning if that is an issue
**
Actually you could just add the necessary cygwin dlls to your projects make and then you would beable to run it in windows
I managed to make my POSIX project run when I added following dlls
cygboost_filesystem.dll
cygboost_system-mt-1_53.dll
cygboost_thread.dll
cyggcc_s-1.dll
cygstdc++-6.dll
cygwin1.dll
Probably your project will have different dependencies, however if you think conversion is not worth it, then perhaps this is a solution for you
You could also add your libs as static, then you would end up with only having to provide the last cygwin1.dll

Resources