Porting windows C++ code into Linux

L

Lior

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.h> and <winbase.h>. Do they have linux-
alternatives?

Thanks,
--Lior
 
J

John Harrison

Lior said:
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.h> and <winbase.h>. Do they have linux-
alternatives?

Thanks,
--Lior

No, because <windows.h> is 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
 
I

Ian Collins

Lior said:
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.
 
S

Sarath

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.h> and <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.
 
S

saf

Lior said:
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.h> and <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).
 
K

kumar.rangarajan

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.h> and <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"
 
V

Victor Bazarov

[.. 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
 
M

Markus Schoder

[.. 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top