By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

Porting windows C++ code into Linux

P: n/a
Hi,

I have small code, that compiles on Visual C++ into a shared library
(DLL).

I need to compile it under linux, but the code includes some data
types I'm not familiar with, such as DWORD, HANDLE, __int64, ULONG
etc.

What are those words?

The code also includes <windows.hand <winbase.h>. Do they have linux-
alternatives?

Thanks,
--Lior

Jun 17 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Lior wrote:
Hi,

I have small code, that compiles on Visual C++ into a shared library
(DLL).

I need to compile it under linux, but the code includes some data
types I'm not familiar with, such as DWORD, HANDLE, __int64, ULONG
etc.

What are those words?

The code also includes <windows.hand <winbase.h>. Do they have linux-
alternatives?

Thanks,
--Lior
No, because <windows.his the API of the Windows operating system.

Some of the types you mention have obvious equivalents, DWORD and ULONG
are 32 bit unsigned integers (might not be so on a 64-bit architecture
though). __int64 is a signed 64 bit integer (obviously). But HANDLE does
not have an obvious Linux equivlanent since it represents some operating
system resource.

But since Windows is so prevalent, and since some Windows programmers
seem unaware of the world beyond Windows, you do see a lot of code that
is needlessly Windows specific.

Maybe your code is like this and you'll find it fairly easy to port, but
without seeing the actual code it's impossible to say.

This isn't really on-topic on comp.lang.c++ which doesn't deal with
platform specific topics (even when its porting from one platform to
another). So you should probably ask again in a Windows group or a Linux
group whichever you think is likely to get you the best answer.

john

Jun 17 '07 #2

P: n/a
Lior wrote:
Hi,

I have small code, that compiles on Visual C++ into a shared library
(DLL).

I need to compile it under linux, but the code includes some data
types I'm not familiar with, such as DWORD, HANDLE, __int64, ULONG
etc.

What are those words?
Topicality aside, the first thing you should do to determine whether it
is possible to port from one platform to another is to remove as many of
the the original platform's quirks from the code, while keeping it
building it on the original platform.

So in this case, start by replacing all the windows specific types with
their standard equivalents, then remove the windows headers and see what
breaks.

--
Ian Collins.
Jun 17 '07 #3

P: n/a
On Jun 18, 4:58 am, Lior <lio...@gmail.comwrote:
Hi,

I have small code, that compiles on Visual C++ into a shared library
(DLL).

I need to compile it under linux, but the code includes some data
types I'm not familiar with, such as DWORD, HANDLE, __int64, ULONG
etc.

What are those words?

The code also includes <windows.hand <winbase.h>. Do they have linux-
alternatives?

Thanks,
--Lior
If you are using some windows API or something, it will be difficult
to port as they're not available in Linux environment as they're
different. If your code is pure C++, yes you can port it with minimal
change else it would be difficult if you are calling platform
dependent calls.

So first decide whether it is portable or not. If you are doing some
stuffs like Windows Programming, Qt is an alternative. I'm not saying
that your code is portable to Linux using Qt. But you can use Qt in
Windows and Linux as it provides Cross Platform libraries.

Jun 18 '07 #4

P: n/a
saf
Lior wrote:
Hi,

I have small code, that compiles on Visual C++ into a shared library
(DLL).

I need to compile it under linux, but the code includes some data
types I'm not familiar with, such as DWORD, HANDLE, __int64, ULONG
etc.

What are those words?

The code also includes <windows.hand <winbase.h>. Do they have linux-
alternatives?
This data types and header files are not POSIX platform compatible. You
need to convert the data types and to remove the windows and winbase
header and to replace it with a Linux alternative. I guess this header
files are only used for Windows system calls which must be replaced by
POSIX system calls (in your case Linux).

--
saf
E-Mail protected against spam: ih******@smtp2.trashmail.net
Jun 18 '07 #5

P: n/a
On Jun 18, 12:58 am, Lior <lio...@gmail.comwrote:
Hi,

I have small code, that compiles on Visual C++ into a shared library
(DLL).

I need to compile it under linux, but the code includes some data
types I'm not familiar with, such as DWORD, HANDLE, __int64, ULONG
etc.

What are those words?

The code also includes <windows.hand <winbase.h>. Do they have linux-
alternatives?

Thanks,
--Lior
While there are no direct equivalents on Linux for these windows
header files (and thus their corresponding DLL's), tools like WinDU
(http://www.bristol.com/windu/ http://www.s7solutions.com/wind.asp)
and MainWin (http://www.mainsoft.com/solutions/prof_svcs_ul.aspx)
exist, which provide a Windows library layer on top of Unix/Linux
OSes. You can compile your windows application by linking with these
libraries and get them to work natively on Unix/Linux boxes.

:-)

S7 Software Solutions
"Where Migration meets Innovation"

Jun 19 '07 #6

P: n/a
ku**************@gmail.com wrote:
On Jun 18, 12:58 am, Lior <lio...@gmail.comwrote:
>[.. need to port Windows app to Linux ..]

[.. WindU, MainWin recommendation ..]
Those are prohibitively expensive.

Consider trying to just run your app under WINE. No need
to even rebuild it, in many cases. The best solution of
course, is to use portable (cross-platform) libraries for
the "other" stuff (not business logic), like Qt, MySQL,
OpenGL, etc. You basically offload the porting onto their
shoulders.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 19 '07 #7

P: n/a
On Tue, 19 Jun 2007 08:39:44 -0400, Victor Bazarov wrote:
ku**************@gmail.com wrote:
>On Jun 18, 12:58 am, Lior <lio...@gmail.comwrote:
>>[.. need to port Windows app to Linux ..]

[.. WindU, MainWin recommendation ..]

Those are prohibitively expensive.

Consider trying to just run your app under WINE. No need to even
rebuild it, in many cases. The best solution of course, is to use
portable (cross-platform) libraries for the "other" stuff (not business
logic), like Qt, MySQL, OpenGL, etc. You basically offload the porting
onto their shoulders.

V
Part of the WINE project is libwine which is meant to provide the Windows
API as a library on other platforms. A package called libwine-dev or
similar (depends on the distribution) probably needs to be installed in
order for the header files to be available.

--
Markus Schoder
Jun 20 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.