Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm looking for something to abstract the standard operating system functionality in C/C++: span/kill a thread, send/receive a message, start/stop a timer, maybe even memory management, although I can probably handle that myself with my own buffer pool.
I want to to be able to develop and unit test on Linux/windows and then recompile the c/c++ code for various target O/Ses (for embedded systems: eCos, FreeRTOS, VxWorks, etc)
Something as "light" as possible would be best, hopefully just a library, maybe even a collection of macros.
Have you looked at the Boost library? It has threads, timers, memory management, and a signals library.
The library is not a small download, but most of the library components are header-only implementations (though the OS abstraction libraries tend to have to be linked), and you only have to use what you need.
I keep a (long) list of OS Abstraction Libraries. Hope it helps.
Why don't you directly call only POSIX functions (POSIX1 seems to fill all your needs) and install a POSIX layer above non-compliant operating system (to be read as Microsoft Windows)?
I think boost is worth to look into; it can provide you an os abstraction, but also a compiler independence, and much, much more. It does require C++ of course. Other options: Posix.
In your list:
eCos, VxWorks, Linux : good posix support, so you can use this.
freertos: see link
Windows lacks good posix support out of the box (see wikipedia Posix)
If cygwin is ok for you, you can propably use it. If you need to mix with Visual Studio, a library like boost seems more interesting (you'd abstract away from it)
Related
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 3 years ago.
Improve this question
Let me explain further ..
Is it advisable to use , something like :
#ifdef _WIN32
void someFunction()
{
// windows version of the function which makes Windows API Calls
}
#elif defined(__linux__)
void someFunction()
{
// linux version of the function which makes POSIX calls
}
#endif
OR create separate source code files for each operating systems, and then use conditional codes in makefiles or any build tools to compile the source code based on the operating system ???
First of all, "best" is at some level opinion-based and might get this question closed. However, my view is that you should work from a standpoint that there is one set of Portable Operating System Interfaces (+X), and that these are what you code to. Then, for systems that lack some or all of the portable interfaces, you can provide drop-in replacement implementations built on top of whatever OS-specific interfaces the particular oddball operating system wants you to use.
This allows you to keep complex conditionals and OS-specific logic out of your actual program logic, and isolate it all as platform-support shims. Some people prefer to do this by building their own portability layer (APR, NSPR, etc.) and treating POSIX just as one of the backends for it. I strongly recommend against doing this, since:
It imposes significant levels of overhead on systems that already have a portable interface.
It makes your code hard to read by people who know the standard interfaces but who aren't familar with your own portability layer.
It makes your code hard to reuse in projects where your portability layer isn't a good fit.
It's a huge rabbit hole of yak-shaving that will bog you down and take all your time away from whatever you actually wanted to code.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I know that win32 API is written in C language and also why Qt is portable?
Could someone explain this to me?
Because WinAPI was not designed to be portable as it targets only the Windows OS while the QT framework targets multiple OS-es. The fact that WinAPI was written in C does not make a difference.
The windows API is portable in the sense of being processor agnostic (indeed, it has run on many non-Intel processors over the years). It is not portable in the sense of being OS agnostic; although even there Microsoft's is not the only implementation of the API. The wine project has done a credible job of re-implementing the API for other platforms, to the point that windows binaries will run, at least on processors that match the binary.
The fact that the WinAPI is aimed at C makes no difference.
Just because the language is cross platform it does not mean the library (especially in the case of those like WinAPI which are not in the standard library) are the same.
It's just a library that interacts with the video card/processor to make a GUI on a very low level. At this point it is so low level the process depends more on memory locations or processor specific operations. IE saying that certain memory locations (specific to the OS) will reference a pixel on a screen ect.
The Win32API has been built so that it only "knows" the tasks for computers with Windows OS, libraries like QT, once again are still not truly "cross-platform" they have just been built to include all the relevant operations needed for each OS it covers.
Why is a rather open question; but here's my take on it:
Win32 API is produced by microsoft; which has commercial reasons for not being portable.
QT is open source; which was created with the sole intention to be portable.
Bonus:
X11 is open source; which was created with the idea that the machine displaying the images might not be the machine running the program that wants the window. Which makes it inherently non-portable to other APIs that don't (eg windows)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How can I do multi-tasking and inter-process communication in Fortran?
The main standards to read up on are OpenMP (shared memory multi-threading) and MPI (message passing). Both work well with Fortran (as well as other languages) and you will find a lot of information online.
OpenMP defines a simple way of programming concurrent (parallel) processing in Fortran/C/C++. The process must reside in a same computer (node).
OpenMP 3.0 recent introduces $OMP TASK directive which in principle should allow multitasking the way multithreading is usually done (that is, each thread does its own task). For OpenMP, see this tutorial:
https://computing.llnl.gov/tutorials/openMP/
or specs in http://www.openmp.org/
I won't address interprocess communication (IPC) since I am not familiar with this. I believe you can do POSIX function calls if that what you want. If your compiler supports some Fortran 2003 constructs (e.g. gfortran >= 4.4) then you can use the nice C-Fortran interoperability provided by ISO_C_BINDING standard module. Then with proper care you can call posix functions that can provide IPC functionalities. That's my 2c.
Fortran2008 also has coarrays, which allows distributed-memory computing from within the language itself, and do concurrent, which allows for functionality similar to an OpenMP parallel do loop. Right now, only the newest intel compiler fully supports these, and g95 has partial support; however, they are actively being worked on by the other compiler vendors, including gfortran.
You do concurrency in Fortran in the same way you would do this in any other language: Spawn a pthread, use OpenMP, use MPI, fork() ... whatever suits your need best.
Systems APIs are often in C (cf. POSIX and Windows API), but interacting with C is a fact of life, regardless of which programming language you use.
The "do concurrent" contruct in Fortran 2008 still does not have a lot of compiler support, even in 2015.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I was wondering if there was an API to do networking that would work on Windows, Mac and Linux. I would like to make a card game that 2 people can play through a TCP connection.
There are a few options for this, some easier to use than others:
APR (Apache Portable Runtime) - Very popular. Quite easy to use. Includes lots of additional features handy for network programming (threads, mutexes, etc.)
ACE - Popular among the embedded space. Personally, I found it quite a complicated API, and not very straightforward to use.
Boost - If you have a decent level of sophistication with C++ (templates, metaprogramming, etc.), then Boost libraries are generally very good. I'm not sure how popular the Boost asynchronous networking libraries are in the real world.
QT - Popular as a UI toolkit, but has a great set of threading, event management, networking libraries. IMO, this is by far the easiest to use.
It's important to stay away from using the berkeley sockets library, as the implementations across operating systems vary wildly, and you'll lose a fair bit of time to tuning them as you port your software across OSs.
My personal preference: APR.
most of the berkeley sockets api works everywhere.
You can use ACE or Boost.Asio:
About ACE:
Increased portability -- ACE components make it easy to write concurrent networked applications on one OS platform and quickly port them to many other OS platforms. Moreover, because ACE is open source, free software, you never have to worry about getting locked into a particular operating system platform or compiler configuration.
About boost:
Boost.Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.
The NRL has a really great library of networking methods that supports a large variety of platforms. They have excellent support from the actual developers on their mailing lists as well.
Protolib
For this simple application you can use the standard "Berkeley socket" functions that are mostly portable. You can also use Boost's abstractions.
If you needed security functions like SSL/TLS (which you don't need for a simple game I guess), there are open source libraries like OpenSSL, GNU TLS, Mozilla NSS.
I've got a feeling the Apache Portable Runtime might help with what you're looking for. Apache HTTPD used this library internally to abstract its platform-specific code so that the server code focuses on the logic and calls the methods in the APR and these translate to underlying operating system functions.
Of course, it might have more tools in it than you strictly need...
Synapse is good multiplatform network library. Open source and very easy to use.
http://www.ararat.cz/synapse/doku.php/download
SDL Net is a very simple abstraction layer on top of sockets, that's very easy to use. See http://www.libsdl.org/projects/SDL_net.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a minimal and easy to learn C or C++ cross platform gui library.
In a nutshell I only need the following functionality:
application window
menu bar
some simple dialogs, File-open and save. Maybe a user-written one.
user canvas where I can draw lines an circles on.
some kind of message/event loop mechanism.
Target platforms would be Win32 and linux. MacOS would be nice to have but is not important at the moment.
Why am I looking for something minimal? I don't want to spend much time to learn a big and full blown abstraction system for a really small application. The easier and leaner, the better.
Any suggestions?
If you need something small, try FLTK libs: I used them at work (embedded development) and I think it's a valid option. Maybe apps are not as "cool" as QT-based ones, but developing with FLTK libs is fast and easy.
I don't know about minimal, but Qt is pretty easy to learn.
Its light-weight enough to run on embedded devices, so you be the judge.
EDIT after seeing the comments:
Yes, Qt is a fullblown application framework, but here's my case: an app with cross platform GUI but other platform-dependent code is not really platform independent. I don't think moving existing C++ code into Qt entails any work at all. If anything, this would allow Nils to use his existing C++ code, and only use Qt for a GUI. But of course, I assume that the existing C++ code is portable.
wxWidgets (formerly wxWindows) is a widget toolkit for creating graphical user interfaces (GUIs) for cross-platform applications. wxWidgets enables a program's GUI code to compile and run on several computer platforms with minimal or no code changes. It covers systems such as Microsoft Windows, Mac OS X, Linux/Unix (X11, Motif, and GTK+), OpenVMS, OS/2 and AmigaOS. A version for embedded systems is under development.
http://www.wxwidgets.org/
See Good C++ GUI library for Windows for relevant answers.
Personally, I would go with Qt, now that it's open. You don't necessarily want a minimal library, you want one that is easy to use, and quality documentation and community support will give you just that.
Small projects have the nasty habit of sticking around and picking up scope -- as things get hairier, you don't want to be stuck with some small library that nobody knows about.