I have a few projects where most of the code is written in platform-agnostic C++, with a relatively thin platform abstraction layer for each supported platform. For most platforms this abstraction layer is also written in C++, but for iOS and OSX it also contains some Objective-C code. For this reason, I have Xcode projects for the iOS / OSX builds, and Visual Studio projects for Windows, but I'm a bit tired of having to maintain multiple project files.
It would be so nice to only have one cross-platform IDE, one project file for that IDE, then just add all source files to that, and make some of them included in the build only in certain configurations. But for that I'd need an IDE that runs on multiple platforms (Windows, OSX, preferably linux too), and supports not only C++, but Objective-C source files as well. Is there such a thing?
You can try QtCreator. It's a cross-platform IDE developed for Qt but it supports Objective-c too:
http://qt-project.org/downloads
Related
I'm attempting to use Visual C++ cross platform features to write an SDL 2 app for Windows, Windows Universal, iOS, Android and Linux. I have one project for each platform now I want to abstract the SDL stuff to a common project that each platform project will reference with each project supplying the appropriate SDL libs for the platform through the linker.
Is there a project type in VS that actually allows me to do this? I was hoping the shared items project would do the trick, but I doubt thats the one. There does appear to be some form of shared library for iOS and Android, but it doesn't look like that extends to Linux and Win32.
Thanks,
To make a successful cross-platform application with SDL2, you should, in first place, use a compiler that's available on both platform. Because, you will need to compile a binary for each platform. SDL2 seems to support IOS and Android out of the box, but I don't know how deployment is done for the mobile OS. You can still use Visual Studio with CMake or a Makefile and use another compiler instead of Visual C++ to support a cross-platform build, like g++ (mingw32 on windows) or Clang.
I want to create graphical application (drawing and moving squares and so) using C++. I was suggested to use Qt library for this. I am windows user and I use Visual Studio 2013 for developing C++ (console) apps. So I typed Qt download into google hoping to find some package of DLLs, libs, headers or something like that so I could include headers and link libraries with my code. But all I found was IDE Qt Creator (which I do not want) and Qt Visual Studio plugin (which I downloaded, but it still requires whole IDE to work). So my question is - How can I develop graphical application (no forms, just "canvas" to draw on with some mouse/keyboard support) using Qt library, C++ language and Visual Studio IDE, without requirement of downloading tons of GBs for IDE or plugins I do not want, with insurance that application would be easily deployable on most common operating systems.
The reason I do not want Qt creator IDE is simple -- There is a chance for this to be semester project and will be reviewed by teacher without any extra IDEs. (I'll send him just VS project/generated Makefile and Qt libraries with headers)
Thanks for clarification.
The short answer is: you cannot. You need Qt SDK, which comes with Qt Creator.
Qt comes with qmake build system and it does not require any IDE to compile and run the application. You can write in any IDE you want and compile anywhere, where Qt SDK and compiler is available.
If you want to provide the application to your teacher, he must have Qt SDK too to compile it. There is no way around this. And better test the application in the target environment. Writing portable applications is not a trivial task - if you hardcode paths like C:\QtSDK\path\to\something, there is little chance to run it under Linux without any changes.
If you cannot expect any SDK on a teacher's computer, you have few options:
convince her to install necessary tools
ask her what tools are permitted and stick with them
bring your own computer for final evaluation
I've got new task to research the way of development C++ cross platform (Mac/Win) utility for our internal needs.
I've developed for 7 years using different "pink" languages like C# , Java , Managed C++.
But in this task , the requirement is to support Mac , and .NET that is running on Mac , is really pain (Know this from other guys who did used this).
So I've started to think about C++ if it's possible to use C++ for Cross platform development.
The application will no contain any GUI , but will contain a lot of System API calls , and a lot of business logic analysis.
Is there possible some library allowing to achieve such kind of Task ?
Is it possible to do at all ?
Yes, you can write standard, ISO C++ and run the programs on both platforms.
When you need to implement some functionality using platform specific APIs (e.g. using Win32 on Windows and POSIX APIs on Mac OS) then what you do is write your own wrapper functions that abstract away the platform specific details, and then use that wrapper in the rest of your program.
Tools like CMake will allow you use Visual Studio to build the program on Windows and Xcode to build on the Mac without having to manually manage separate Visual Studio and Xcode project files.
If I understand your question properly, the only thing you need to develop cross platform c++ is to get the right compilers. You could use GCC on both platforms or even use 2 different project files for visual studio and xcode. That's up to you. Personally, I prefer GCC.
Regarding code itself, it depends on what you do with it. STD is available on both platforms (std::vector, std::string, etc) so code should compile properly on both platforms.
Edit: Btw, most platform specific stuff are available through open source code (like boost though I personally don't like boost that much). If needed, you could even look at other open source projects that are cross platform (ogre3d, etc).
I am working with a c++ multi-platform project using visual studio 2010, there is a shared portion of code among all platforms, but there is a big portion that is dedicated to each one, I separate them using #if def, but it turns out that code maintenance become very though and the code is cluttered, in addition to problems like code does not compile with some defines turned on or off.
Is there any plugin or tool for visual studio that helps in developing multi-platform projects, for example hide code related to platform, or compile using different #defines turned on/off, check data types, .. ect.
I would be grateful if any one have a suggestion
I do not know about such a plugin for VS, but since it's basically a Windows-only IDE, I doubt there are any. (But of course I could be wrong)
If you're looking for a good cross-platform build system, I'd look to CMake. It's powerful, easy to pick up and can generate build files for almost any popular IDE/toolchain (Visual Studio Solutions, Eclipse Projects, MinGW Makefiles, GNU Makefiles, etc).
It makes cross-platform development of larger projects a breeze!
You could probably eliminate most of the platform dependent code if you switch to the Qt framework. You can keep to using VS with the Qt add-on and by using the platform abstractions of Qt you can target a number of different platforms with (nearly) identical code base. You get unbeatable platform support and portability:
Windows
Linux (Qt is native to KDE and future releases of Ubuntu)
MacOS
BB10 (Qt is native to BB10 too)
Embedded Linux
Android (coming next month)
iOS (next month too)
Jolla
Tizen
The APIs are also better IMO - less ugly and awkward, more consistent. Also QML (JSON style markup for building applications from C++ components using JS for glue code and value bindings) can significantly boost your productivity (up to 10 times without exaggerating). The Qt toolchain supports different kits (combination of library versions compilers and platforms) and multi-platform cross compilation.
There is no "Tool" more than visual studio itself. Separate the code to different projects; Project for common code and project for each platform.
Don't forget to:
1. Add reference to common project in all platform-dependent projects (so common project is compiled before platform project).
2. Add common project base to the common include directories of each target project.
I have a C++ eclipse project that I would like to easily compile In Windows and OSX.
The project is currently using an automatically generated makefile.
The libraries that I need vary depending on the platform.
In osx I'm using the CoreMidi, CoreAudio, and CoreFoundation frameworks.
In Windows I'm using the winmm.lib and multithreaded libraries.
What's the simplest way to link different libraries/frameworks depending on the current platform?
I'm currently using the gcc toolchain on OSX. Should I start using the cross compile toolchain?
Should I have two projects. One for working in windows, and one for osx, checking them both in to version control?
Should I write a custom makefile instead of using the automatically generated option that has different g++ arguments depending on the platform?
I personally had the same goal for a project and came to the conclusion the Qt framework was the best thing for me. It handles multiple languages, unicode strings, XML, network communications, native looking user interfaces, console applications: it can do an AWFUL lot.
However, as Paul pointed out, you really have to plan it from the start.
Qt does a good job of abstracting the platform away (in a module called QtCore) allowing you to write vanilla C++ code, or you can chose to include some Qt C++ language extensions which a Qt helper application called the moc (meta object compiler) creates vanilla C++ from, which can then be compiled by most common C++ compilers.
It also has a nifty cross-platform makefile generator called qmake which works on project files to create normal make files for the platform its running on.
Off the top of my head at least Windows XP & 7, OSX 10.4, 10.5, 10.6 are supported currently. But note that OSX Lion is (as of writing) not officially supported but I suspect it will be in the next release.
Based on your description, I am not sure you can easily make it cross-platform. Even without using third-party library, you have to provide separate code for osx and windows. Most of time, they design the system as cross-platform first. It's really hard to make an existing project on single-platform to cross-one. If you have the cross-platform requirement, you'd better design in that way first and rewrite from scratch.
Even though Eclipse can run fine on both OS X and Windows, it is not designed to be used in this way.
The best way to do it is to use separate IDE projects for each platform. This this is the easiest way to have unique compilation settings for multiple platforms.
Yes, you can use two eclipse projects. Alternatively, it's not unusual to have a X-Code project for OSX, and a Visual Studio Project for MS Windows.