Are all standard library header files installed with mingw32-gcc-g++ package? [duplicate] - c++

I have been searching to get the source code of the header file <graphics.h> and its associated library in order to integrate it with my C++ program.
At the same time, I am interested in those cross-platform libraries that works on more than one compiler. Just to be more explicit, I am talking about those libraries that are used for drawing shapes, lines, and curves in C++.

<graphics.h> is very old library. It's better to use something that is new
Here are some 2D libraries (platform independent) for C/C++
SDL
GTK+
Qt
Also there is a free very powerful 3D open source graphics library for C++
OGRE

<graphics.h> is not a standard header. Most commonly it refers to the header for Borland's BGI API for DOS and is antiquated at best.
However it is nicely simple; there is a Win32 implementation of the BGI interface called WinBGIm. It is implemented using Win32 GDI calls - the lowest level Windows graphics interface. As it is provided as source code, it is perhaps a simple way of understanding how GDI works.
WinBGIm however is by no means cross-platform. If all you want are simple graphics primitives, most of the higher level GUI libraries such as wxWidgets and Qt support that too. There are simpler libraries suggested in the possible duplicate answers mentioned in the comments.

There is a modern port for this Turbo C graphics interface, it's called WinBGIM, which emulates BGI graphics under MinGW/GCC.
I haven't it tried but it looks promising. For example initgraph creates a window, and
from this point you can draw into that window using the good old functions, at the end closegraph deletes the window. It also has some more advanced extensions (eg. mouse handling and double buffering).
When I first moved from DOS programming to Windows I didn't have internet, and I begged for something simple like this. But at the end I had to learn how to create windows and how to handle events and use device contexts from the offline help of the Windows SDK.

The Borland Graphics Interface, the library fronted by the graphics.h header, has been re-implemented atop SDL. This brings support for modern hardware and operating systems (multiple operating systems, in fact, since SDL is fairly portable).
It can be downloaded here prebuilt for a variety of common desktop targets.
Or if you wish to (or must) build it from source, here is a github mirror.
Note that it is a port of a very old software library and will run atop modern tools, so you should check with the instructor if you intend to use it for class assignments. It would be irritating to fail an assignment because you used idioms that require support from a modern compiler and find that they do not compile on a marking system from the 1980s.
You may find it better to get and develop with a virtual machine clone of the marking system to prevent nasty surprises.

graphics.h appears to something once bundled with Borland and/or Turbo C++, in the 90's.
http://www.daniweb.com/software-development/cpp/threads/17709/88149#post88149
It's unlikely that you will find any support for that file with modern compiler. For other graphics libraries check the list of "related" questions (questions related to this one). E.g., "A Simple, 2d cross-platform graphics library for c or c++?".

Related

zlib for WinRT?

I require zlib library for the development of Windows Store app.
Has anyone converted Win32 zlib project to WinRT yet?
Can anyone please describe the steps to convert the existing win32 static lib project to winRT?
Visual C++ is already a supported language for WinRT development, if you wan't to use zlib, just compile it together with your solution. There is nothing that is preventing you from reusing standard ISO C and C++ libraries from within the WinRT, if you are using the C++ language, you might have to expose certain aspects of your library as WinRT Components but only if you need to interface with facilities like XAML or other WinRT languages but that should be a walk in the park. Not something which is tremendously difficult to do.
The whole point of supporting C++ in the WinRT is to allow an existing ecosystem of largely native applications to be ported to the Windows Store. zlib is not an exception. Non-standard ISO C and C++ such as sockets are not supported but there you have alternatives that you can plug-in to, just check that the library you're using has some kind of portability support.
WinRT is very limited with regards to C library functions which are present. What this means is that virtually all cross-platform C libraries are (AFAIK, I'm not a WinRT dev) unusable for that target.
For the case of zlib, there is an alternative: see this question
EDIT: to clarify what I'm saying above, I dug up a list of all CRT functions that are absent for WinRT, which you can find here. As long as zlib or any other C library does not depend on these function calls, you should be able to use the WinRT tools to build that C library. I even found a project file for zlib on winrt by the Ogre team here, not sure how useful it is to you.
You could take a look into this WinRT (Un)Zip component. Its used in production code already.
See the unit tests inside on how to use the component. It compiles on all WinRT architectures including ARM. It has no custom asm for ARM though.

OpenGL libraries

From OpenGL wiki:
"For most libraries you are familiar with, you simply #include a header file, make sure a library is linked into your project or makefile, and it all works. OpenGL doesn't work that way."
I work on Windows 64 and I need OpenGL to use it in C++ application. What library I should use? Does microsoft provide its implementation ( I use MinGW, I do not have MS Visual C++ )?
The one that comes with your GPU drivers that you have installed on your machine, Microsoft also provides a software layer for OpenGL emulation but it's stuck at the version 1.1 and it's really old and useless.
What library should I use?
I recommend using GLEW for easy access to functions of OpenGL 1.2 and higher, GLM for mathematics, and one of these image loading libraries.
Does microsoft provide its implementation (of OpenGL)?
Microsoft provides you with the necessary header files and library files to access the OpenGL API. However, in order to use OpenGL functions of version 1.2 and higher, you must use extensions. GLEW does this implicitly for you.
Take a look at glew. It loads needed extensions and core functions.

How can I get and use the header file <graphics.h> in my C++ program?

I have been searching to get the source code of the header file <graphics.h> and its associated library in order to integrate it with my C++ program.
At the same time, I am interested in those cross-platform libraries that works on more than one compiler. Just to be more explicit, I am talking about those libraries that are used for drawing shapes, lines, and curves in C++.
<graphics.h> is very old library. It's better to use something that is new
Here are some 2D libraries (platform independent) for C/C++
SDL
GTK+
Qt
Also there is a free very powerful 3D open source graphics library for C++
OGRE
<graphics.h> is not a standard header. Most commonly it refers to the header for Borland's BGI API for DOS and is antiquated at best.
However it is nicely simple; there is a Win32 implementation of the BGI interface called WinBGIm. It is implemented using Win32 GDI calls - the lowest level Windows graphics interface. As it is provided as source code, it is perhaps a simple way of understanding how GDI works.
WinBGIm however is by no means cross-platform. If all you want are simple graphics primitives, most of the higher level GUI libraries such as wxWidgets and Qt support that too. There are simpler libraries suggested in the possible duplicate answers mentioned in the comments.
There is a modern port for this Turbo C graphics interface, it's called WinBGIM, which emulates BGI graphics under MinGW/GCC.
I haven't it tried but it looks promising. For example initgraph creates a window, and
from this point you can draw into that window using the good old functions, at the end closegraph deletes the window. It also has some more advanced extensions (eg. mouse handling and double buffering).
When I first moved from DOS programming to Windows I didn't have internet, and I begged for something simple like this. But at the end I had to learn how to create windows and how to handle events and use device contexts from the offline help of the Windows SDK.
The Borland Graphics Interface, the library fronted by the graphics.h header, has been re-implemented atop SDL. This brings support for modern hardware and operating systems (multiple operating systems, in fact, since SDL is fairly portable).
It can be downloaded here prebuilt for a variety of common desktop targets.
Or if you wish to (or must) build it from source, here is a github mirror.
Note that it is a port of a very old software library and will run atop modern tools, so you should check with the instructor if you intend to use it for class assignments. It would be irritating to fail an assignment because you used idioms that require support from a modern compiler and find that they do not compile on a marking system from the 1980s.
You may find it better to get and develop with a virtual machine clone of the marking system to prevent nasty surprises.
graphics.h appears to something once bundled with Borland and/or Turbo C++, in the 90's.
http://www.daniweb.com/software-development/cpp/threads/17709/88149#post88149
It's unlikely that you will find any support for that file with modern compiler. For other graphics libraries check the list of "related" questions (questions related to this one). E.g., "A Simple, 2d cross-platform graphics library for c or c++?".

How to port a PC game to Android written in C++

I want to create a simple game like Space Invaders. I know that I can use Android NDK, but I have to port the libraries that I use. I can not use third-party proprietary libraries.
I will use OpenGL, but OpenGL API seems different on Android. I have to use jpeg and png textures, and write texts. Can I compile libjpeg, libpng and freetype for Android?
I can not have specific implementation of the game engine (C++) and rendering routines (C++ and OpenGL), because that is the complex part.
There are components that I am disposed to implement for each platform. There is no problem with windowing system and user input, because I will use a specific implementation for each system, it is simple for me.
I use SDL and its extensions for audio on PC, but it is easy to use. I can use specific audio libraries for Android.
Thanks
Can I compile libjpeg, libpng and freetype for Android?
Yes you will have to recompile all the native libraries specifically for Android. Yes, you do need the source code for all 3rd party native libs you plan to use simply because Usually when we compile and link these libraries outside Android they are linked to glibc but unfortunately Android doesn't use glibc due to liscence and performance issues. Android uses a watered down version of glibc called libc. It has matching symbol names to glibc for most of the usual functionalities. But as far as i know the libc doesn't have some functionality related to Strings and it definitely doesnt have some posix support. If your native libraries are using any of the deprecated functionality you will have to find workaround for those by using alternative functionality supported by libc and coding your libs accordingly.
Also, as you righty pointed out you will have to use the NDK to interface Java(Android app/fwk) to native world(C++).
Though this sounds pretty simple in my experience compiling native libraries on Android(Android porting) has traditionally been very time consuming with no guarantee of sucesses.

C++ API for multiplatform development

I want to learn C++ to work on various platform (primarily, Linux and Windows). I have come across few solutions like the Boost C++ library, Qt toolkit, etc that can be used to write programs which will compile on both the platforms.
I want to know from the community, what type of library would you refer to use and if any of you had experience with this type of multi-platform programming before.
Use Qt and the BOOST C++ Libraries. They are both free and very high quality. Also, at least for me personally, I found Qt to be much more straightforward, easy to learn, and simpler than wxWidgets.
It depends on what you're going to do. If you need to write a strictly command-line utility to process text, Qt or wxWidgets might be inappropriate. What exactly is your application field?
Scientific computing is my field of expertise. in which these are great multi-platform APIs:
Parallel Programming
MPI
OpenMP
Numerical Algorithms
BLAS (via Boost's C++ wrappers for BLAS)
LAPACK
LINPACK
PETSc
High-performance file I/O
HDF
NetCDF
Visualization
Visualization Toolkit
If you're doing viz work, a GUI can be great. Try one of the following multi-platform APIs:
Qt
wxWidgets
GTK
The plugin framework for the parallel viz apps:
Paraview
VisIt
You didn't specify any partuclar type of library, but if you just want a general recommendation I have to say wxWidgets is an excellent cross platform GUI library.
It has some great features like rendering the GUI in the native look and feel of the operating system it's running on, and is not particularly hard to learn. It offers a single API for GUI writing across Win/Mac/Linux, plus others like WinCE.
I highly recommend it for cross platform GUI work.
Check it out at http://www.wxwidgets.org/
I highly recommend Qt if you are doing any sort of GUI work; it's even quite useful if you aren't, since it has well-thought out networking/database/container/etc APIs also. It's a very well designed API and very easy to use.
The core C++ standard and the STL are pretty much cross platform already. Its usually only the GUI and hardware access stuff that requires libraries.
I have used GTK+ as a GUI toolkit and it's pretty good too, although you need to install glib and some other stuff on windows.
RtAudio is nice for cross-platform audio I/O.
The low level networking/sockets stuff is largely the same between windows and linux, you could write a very lightweight layer yourself to handle any differences. I don't have any experience with higher-level networking libraries.
I also like the SFML (simple fast media library) for cross-platform 2d graphics type stuff. It's very nice indeed.
I would suggest, however, that if you are just learning c++ then you're probably better off not looking at Boost (or indeed any of these toolkits) until you've got your head around the basics - by writing a couple of basic console applications, for example.
If you want to learn c++ only so you can do multi-platform dev, be aware that there are many other languages and associated toolkits that may be more suitable, depending on the app you're writing.
Without knowing the type of app you're planning on developing, its hard to say whether C++ (or C or Python or whatever) is the best idea. Personally, I generally turn to Python + PyGTK for crossplatform GUI apps and C# for windows-only apps. You can always plug C/C++ in to replace any components that are running too slowly.
Like other posters have mentioned, I would recommend Qt and Boost for cross-platform development. I had tried gtkmm which is a thin C++ wrapper around GTK+, but was not satisfied with it partly because it's not a native C++ library and documentation is poor compared to Qt. Besides that, Qt comes with very nice development environment including a easy-to-write make alternative qmake and a gui designer.
I for are going to do some cross platform development in C++ an you don't want to maintain different build systems (Makefiles, Visual Studio Projects, etc) there are several tools out there that can help you.
The one I personally use is CMake. It supports Linux and Unix Flavours, Windows and Mac/OS. Actually several open source projects, like KDE, use it. But there are others options like for instance Scons.
Standard C++ programs will compile and be portable, i.e. work across a large range of platforms. To be sure that you are keeping code clean, your best bet is to get a few different compiler and check your code with all of them, while enforcing full standard conformance (with options like -std= for g++, for example) and writing warning-free code (with options such as -W -Wall -Werror for g++, which emits errors instead of warnings). The exact choice of compilers is up to you, but if you're mostly learning, I advice using:
g++ (free, open source)
the Intel compiler (free for noncommercial use on Linux)
maybe MSVC++
Also, if you really have to use compiler- or target-specific code in your projects, be sure to abstract it so it's all gathered in one place, and hidden from the rest of your code.
Now, if you want to use more than the STL, then you need to choose your libraries by considering the range of compilers and platforms they're tested against (and, if the documentaiton doesn't state it, it's a bad omen). The detailled choice depends on what exactly you want to do, but Boost (as a robust, wide-ranging library for many common issues) and Qt (a recent version; for GUI programming) are good choices. For numerical, scientific programming, BLAS/LAPACK (and/or their parallel versions, BLACS and Scalapack) are very widely used, directly or through wrapper C++ classes as can be found in Boost (for BLAS); a good FFT library is also often needed (FFTW is good if its GPL licence is not a burden for you).