Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Cross compiling with GTK+


  • Please log in to reply
13 replies to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:31 PM

Posted 23 December 2009 - 03:38 PM

Hey, I am currently running Ubuntu and have been making some GTK+ programs in C++ with it, I have recently got cross compiling working so I can compile a C++ program on my Linux as a working Windows executable. I am now looking to go deeper into that and cross compile with GTK+, dose anyone have any ideas, there dose not seem to be that much help out there for this particular problem.

Thanks for any help you can give me, Wolfy87.

BC AdBot (Login to Remove)

 


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:06:31 AM

Posted 23 December 2009 - 04:39 PM

Only major downside is that your windows app will not be able to support Unicode, as the only windows compiler which runs on linux does not support the unicode bits (wchar_t, wstring, wstream, etc) of the C++ standard.

MinGW is a win32 compiler, which itself can be compiled on Linux.

Honestly though, GTK+ isn't great in the windows environment -- things don't come through looking native. Plus you force your users to download 20MB+ of GTK libraries to run your application. If you want to do it you can, but I strongly recommend against it.

Hope that helps,
Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#3 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:31 PM

Posted 23 December 2009 - 08:13 PM

I have never seen a gtk app on windows so thankyou for the information, I should just stick to normal horrible windows programming then for that, all of those caps and underscores blagh, gtk works quite well with linux though so atleast theres no problems there.

So if i get the required windows librarys, like windows.h, into my cross compiler (mingw32) can i cross compile windowed programs that use the win api?

Thank you, this has really helped.

#4 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:06:31 AM

Posted 23 December 2009 - 08:58 PM

Hello, Wolfy :thumbsup:

What underscores and blech? Windows is a UTF-16 (Unicode) environment. Linux is not. You and I only probably speak English, but users of other languages, like Japanese, surely enjoy being able to put their native language into some form of encoding. I personally use wide character strings explicitly instead of the TEXT or _T() macros, because I never care about building ANSI applications. ANSI is maintained for compatibility with Windows 9x codebases in any case.

For example:

MessageBoxW(NULL, L"This is my message text.", L"This is the title on my message box.", 0);

The Ls tell the C compiler to encode the string as a wide character string. Welcome to standard features of ANSI-C or ISO/ANSI-C++.

Example GTK+ Apps on Windows:
Pidgin: http://pidgin.im/
The GNU Image Manipulation Program: http://www.gimp.org/

Mingw comes with it's own windows libraries. You cannot use the libraries that come with the Windows SDK because they work only with the compiler that comes with the Windows SDK. Not everything is included. For example, if you want to support unicode on windows, you can't using Mingw, because the C++ standard library wide character functions have not been ported to Mingw. EDIT: You also can't use any type of Component Object Model technologies using Mingw.

You need a windows environment for testing anyway ... why not use the free C/C++ compiler that comes with the Windows SDK in any case?

Hope that helps,
Billy3

PS: It's sometimes difficult to read when you don't take the time to spell and punctuate correctly -- you might get more responses if your wording was clearer.

Edited by Billy O'Neal, 23 December 2009 - 09:00 PM.

Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#5 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:31 PM

Posted 24 December 2009 - 09:57 AM

So my cross compiler, MinGW, should compile a program that uses the windows api and I do not really understand how to use encoding complacency yet, but I am going to look into that, thanks for the tip.

And I have a couple of testing environments, WINE and Virtual Box.

Thank you for all of your help Billy, I'm going to go try create some more windows, I just find the windows code so difficult to memorise where as with all other C++, VB and PHP etc it just clicks.

#6 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:06:31 AM

Posted 24 December 2009 - 10:13 AM

EDIT: Sorry for double post Grrr...

Edited by Billy O'Neal, 24 December 2009 - 10:15 AM.

Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#7 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:06:31 AM

Posted 24 December 2009 - 10:13 AM

Hello, Wolfy :thumbsup:

Hehe -- yes. The initial jump to windows programming can be quite a shock to some. One of the main reasons is that C was invented to target the Unix platform, and several of it's conventions are targeted at users of Unix. Perfect example: char * strings. Windows uses wchar_t * strings instead. And relatively little C/C++ documentation exists for them because most people (unless they're dealing with Win32) don't even bother. You can use the ANSI versions of win32 functions and never bother with the wide character stuff. Using the same example as before:

MessageBoxW(NULL, L"Damnit! I've got to be in unicode!", L"UNICODE!", 0);
MessageBoxA(NULL, "Hey look! This is a plain ANSI message box!", "W00t! I'm in ANSI!", 0);

You can take a look at this book, which is really what got me started in windows development. There's an entire chapter on the TEXT() _() _T() L"" stuff :flowers:

Hope that helps,
Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#8 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:31 PM

Posted 24 December 2009 - 11:01 AM

I will look into that book, it looks really good, dose it matter that I use C++ though, because I have been using C++ for my latest windows programs and this book seems to use C.

If I need to then I will use C but I just prefer C++

Thank you very much for this.

#9 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:06:31 AM

Posted 24 December 2009 - 02:23 PM

Win32 is a C api, unfortunately.

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#10 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:31 PM

Posted 26 December 2009 - 03:21 AM

That could be a problem, I've always compiled as C++ with no errors, I know there similar but not that similar.

#11 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:06:31 AM

Posted 26 December 2009 - 12:16 PM

C++ is backward-compatable with C. :thumbsup:

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#12 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:31 PM

Posted 29 December 2009 - 09:58 AM

Ok I have looked into ncurses, it dose exactly what i want and is a lot simpler, the only problem is I can only get it to compile on my Ubuntu, apparently there are windows ports but I cant seem to find them, there is pdcurses but I cant work that one out.

My best bet I feel would be to cross compile on my Ubuntu box to a windows executable using the ncurses library, do you have any idea how I would go about doing that? Or if you could point me in the right direction, thank you for all of your help so far, its made everything so much easier.

#13 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:06:31 AM

Posted 29 December 2009 - 10:23 AM

I'm a bit confused at this point. Where did curses come into this?

Seriously though, ncurses is a unix library. It's the standard way of manipulating the console on unix boxes, but it's not going to be easy getting it working on windows. You can, however, use the standard Win32 Console Functions to achieve the same effect for windows applications.

Hope that helps,
Billy3

PS: It's likely a limitation of MingGW could be the issue -- it's based on a very old (3.x) version of the GNU Compiler Collection. Make sure your curses library supports 3.x -- that might make things easier. But in all likelihood the problem is that your library relies on unix api calls that don't exist on win32.
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#14 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:31 PM

Posted 29 December 2009 - 12:47 PM

Yes, sorry about that just found a new library and was interested by it, thank you for all your help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users