You are not logged in.

#1 2011-04-04 21:13:28

aport
Member
From: San Diego
Registered: 2008-02-20
Posts: 99

C for a "cross-platform" application

I'm a C developer, and unfortunately, only a C developer. To date, all of the applications I have written have been for linux (specifically embedded), but I am now interested in writing desktop applications. Applications which I would like to run on Linux and Windows.

For my new venture in Windows programming, I grabbed some C++ books, downloaded VS 2010 Express, and started reading WIN32 API.
So far, after a week, I am not too thrilled about this new environment. Classes seem nice, but I am more comfortable with plain old structures and function pointers.

So, basically, I would like to write an application in C, then create two native front-ends, most likely GTK and WIN32. I could just write it once in Qt and be done, but there's that whole C++ thing again. I found some examples of WIN32 C GUI programming, and it looks like I should be good to go. I've never done GTK, but it's C, so I'm not too worried.

I suppose my question is:
Is this a waste of time? Should I just learn C++ and do Qt?

Offline

#2 2011-04-04 21:23:21

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: C for a "cross-platform" application

AFAIK, GTK works on windows.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#3 2011-04-04 21:25:30

aport
Member
From: San Diego
Registered: 2008-02-20
Posts: 99

Re: C for a "cross-platform" application

Stebalien wrote:

AFAIK, GTK works on windows.

I've read this as well, but I think from the information I've gathered, WIN32 > Qt > GTK, as far as appearance and features go.

If this info is outdated, and GTK+ does indeed work well on Windows, then I suppose I'm all set.

Offline

#4 2011-04-04 21:39:09

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,308

Re: C for a "cross-platform" application

AFAIK, GTK works on windows

I tried.  Really, I tried.  Very frustrating.

You might want to look at wxWidgets.  It runs really well on Windows.  I do my development on Linux, then cross compile (in Linux) to make Windows executables. 

I may be beating my own drum, but look at http://sourceforge.net/projects/pdp1spacewar/.  It is also in the AUR tongue 
This was written in C++,

You might also look into Qt.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2011-04-04 22:13:49

aport
Member
From: San Diego
Registered: 2008-02-20
Posts: 99

Re: C for a "cross-platform" application

Would it be practical to write the application in C, then do the GUI work in some higher level language like Python?

Are there any open source projects which operate like this?

Offline

#6 2011-04-04 22:16:18

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: C for a "cross-platform" application

I useg wxWidgets. Natively, it uses C++, but there are bindings for many languages. The reason I use it is because wxWidget applications looks completely native on any operating system.

There are C bindings for wxWidgets, but after a quick look at the wxC project page, I'm not sure how usable it is. hmm

I tried programming a GUI by using the Windows API itself. The Windows API infuriated me, so I stopped.

I don't know if I'd recommend learning C++. I started as a C programmer and love C. I recently tried learning C++, but decided it drives me crazy. I now use Python if I want to write something quickly and C if I want to write something that is fast or compiled.

Offline

#7 2011-04-04 22:22:30

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,308

Re: C for a "cross-platform" application

drcouzelis wrote:

I  I now use Python if I want to write something quickly and C if I want to write something that is fast or compiled.

Or, use both.  Write the GUI and main loop in Python, and call 'C' functions as required.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#8 2011-04-04 22:35:30

aport
Member
From: San Diego
Registered: 2008-02-20
Posts: 99

Re: C for a "cross-platform" application

ewaller wrote:
drcouzelis wrote:

I  I now use Python if I want to write something quickly and C if I want to write something that is fast or compiled.

Or, use both.  Write the GUI and main loop in Python, and call 'C' functions as required.

Excellent. This pretty much answered my question.

I also did not want to spend a large deal of time writing the GUI. I'd like to focus my efforts on the application, then "whip up" a GUI using something like PyQt.

Are there any open source projects which do this? The first (and really nice) cross-platform project I looked at was Transmission. They actually have native front-ends for GTK, Qt, and Mac OSX. I can imagine that it is a good deal of work, but IMO the end result is much better desktop integration on each platform.

Offline

#9 2011-04-05 06:29:20

Google
Member
From: Mountain View, California
Registered: 2010-05-31
Posts: 484
Website

Re: C for a "cross-platform" application

I have been learning C++. I was pretty much a dedicated C programmer and let's just say I have been enjoying C++. It was pretty complicated to wrap around at first but the more I learn the more I see myself using it. C will always have its uses and for me it will always be my goto language for most quick things (along with Perl, another favorite of mine). C++ is becoming my goto for larger applications.

I think wxWidgets is pretty sweet... native GUIs on multiple OSes.... hard to beat that.

Offline

Board footer

Powered by FluxBB