Winelib: How can I compile a Borland C++ Builder application

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Néstor Amigo Cairo

Winelib: How can I compile a Borland C++ Builder application

Post by Néstor Amigo Cairo »

Hi!

I'm new to winelib. I'm trying to port a Borland C++ Builder 6.0
application, but I need VCL library: vcl.h.

Any ideas?? I would want to make it run natively on Linux.

The code is as follows:

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
USEFORM("textS.cpp", TextStuff);
USEFORM("aboutS.cpp", AboutBox);
USEFORM("assembleS.cpp", AssemblerBox);
USEFORM("chksaveS.cpp", ChkSave);
USEFORM("mainS.cpp", Main);
USEFORM("optionsS.cpp", Options);
USEFORM("editorOptions.cpp", EditorOptionsForm);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->Title = "EASy68K";
Application->CreateForm(__classid(TMain), &Main);
Application->CreateForm(__classid(TAboutBox), &AboutBox);
Application->CreateForm(__classid(TAssemblerBox),
&AssemblerBox);
Application->CreateForm(__classid(TChkSave), &ChkSave);
Application->CreateForm(__classid(TOptions), &Options);

Application->CreateForm(__classid(TEditorOptionsForm),
&EditorOptionsForm);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
//---------------------------------------------------------------------------

--
Néstor Amigo Cairo
+34 687 96 74 81
[email protected]
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Winelib: How can I compile a Borland C++ Builder applica

Post by vitamin »

Néstor Amigo Cairo wrote:Hi!

I'm new to winelib. I'm trying to port a Borland C++ Builder 6.0
application, but I need VCL library: vcl.h.

Any ideas?? I would want to make it run natively on Linux.
You can't. Winelib still requires Wine to run it. It's a library not an executable. If you want to write native Linux application that can run by itself then ... Wine won't help you there.

Winelib is to use win32api _AND_ POSIX api in one program at the same time. If you need one or the other - forget about winelib.
Néstor Amigo Cairo

Winelib: How can I compile a Borland C++ Builder application

Post by Néstor Amigo Cairo »

So I will need to rewrite the application to run on Linux, but this
sounds strange, doesn't it?? I have not completely understood then the
purpose of winelib. Do you mean that it is not possible to build an
application from source (written using Win32 API) using gcc on Linux
and executing it natively?? Of course, it would need winelib to
execute, but is it not like that??

I'm completely confused right now. I would be happy if I could port a
Borland C++ Application which executes Ok under wine to be able to run
it on Linux natively. I can do it from sources, since it is FLOSS.
There's no problem if I need winelib to link the application, the
important thing is to be able to share the same sources between
platforms, not having to rewrite the API related stuff, but to be able
to debug the application and so on using native tools (not having to
compile under Win32, then trying on Linux + wine).

Here's is what I understood (correct me if I'm wrong):
1) Applications designed to compile under Windows use Win32 API and
standard C++. C++ is 99% compatible with GCC, only needs some little
fixes, but Win32 API is completely different from Gnome/KDE...
2) Winelib implements an API which glues Linux OS and libs with Win32 apps.
3) You can use gcc to compile Win32 C++ code if you have the right
libraries, which winelib provides (in addition to STL ones, which are
supposedly standard between platforms). Then, it creates an executable
which links against winelib, but is an ELF executable. It won't be a
GTK/Qt application, but it will run natively on Linux, so I'll be able
to debug it as any other application, using DDD and so on.
4) Some GTK/QT stuff could be added then, so the application would
resemble more a Linux "standard" one, but still not breaking
compatibility with existing Win32 API (for Windows users).

If I'm right, the question is: where can I find the Visual Component
Library compatible headers to build the application?? Are they inside
of winelib??

2008/7/19 vitamin <[email protected]>:
Néstor Amigo Cairo wrote:
Hi!

I'm new to winelib. I'm trying to port a Borland C++ Builder 6.0
application, but I need VCL library: vcl.h.

Any ideas?? I would want to make it run natively on Linux.
You can't. Winelib still requires Wine to run it. It's a library not an executable. If you want to write native Linux application that can run by itself then ... Wine won't help you there.

Winelib is to use win32api _AND_ POSIX api in one program at the same time. If you need one or the other - forget about winelib.






--
Néstor Amigo Cairo
+34 687 96 74 81
[email protected]
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Winelib: How can I compile a Borland C++ Builder applica

Post by vitamin »

Néstor Amigo Cairo wrote:So I will need to rewrite the application to run on Linux, but this
sounds strange, doesn't it?? I have not completely understood then the
purpose of winelib. Do you mean that it is not possible to build an
application from source (written using Win32 API) using gcc on Linux
and executing it natively??
Correct. You can't run it directly only with Wine. (binfmt does not count)

You can't just link with winelib and make your app Linux native. Wine implements totally different API that requires an environment to run in. And Wine is that environment.

Few examples:
1. win32 threads and posix threads are totally different things. They can't be mixed or exchanged. Same applies to most synchronization primitives.
2. POSIX does not have anything close to what win32 handle is.
3. File system name space.
4. Registry is totally alien to *nix but it's a must for any windows app (even if it's not using it directly).

None of those things can be magical created by linking to a library.
mikolajz
Level 2
Level 2
Posts: 20
Joined: Wed Feb 27, 2008 7:18 am

Post by mikolajz »

Winelib allows you to compile a Win32 application to an ELF binary that can be run directly on Linux (provided the winelib is installed). But, if I understand correctly, vitamin wouldn't call such an application native, as the winelib is quite a big dependency (e.g. your application will still create the ~/.wine wineprefix). However, technically it will be a correct native binary and it should be possible to debug it using Linux native debuggers.

A bigger problem can be the VCL. It uses some Borland's C++ extensions (like properties and events) that are not handled by gcc. Also, I think winelib doesn't allow linking to binary DLLs (I think only the builtin *.dll.so and Linux native *.so), so you would need also to recompile VCL into a *.dll.so and, due to the mentioned extensions, I don't think it will be possible. Thus, I don't think it will work as winelib without some kind of a rewrite of the GUI.

You can check, however, if this works under Wine. Then you can load the binary vcl.dll and your binary compiled with Borland's compiler. There is a high probability it will work. AFAIK big apps ported using Wine usually ship an *.exe and the Wine runtime.
Jan Jezabek

Winelib: How can I compile a Borland C++ Builder application

Post by Jan Jezabek »

You have at least a few options:
- try to use Kylix (yes, it also supports C++). The downside is that
it's old and not really supported,
- compile and link your program on Windows and use Wine. It will be no
less 'native' than a Winelib application,
- port it to ObjectPascal :p, and try to use Lazarus
(http://www.lazarus.freepascal.org/),
- consider a switch to another framework - Qt and GTK (e.g. using gtkmm,
GTK's C++ binding).

Winelib does not make it possible to create a standalone ELF executable
- this would create more problems than it would solve. Still even if it
did the VCL uses Borland's extensions as mikolajz said (and is a
proprietary product in the first place - there is an open-source version
called FreeCLX, but I doubt it will work with anything other than
Borland's C++ compiler).

Jan Jezabek

--
My GSoC 2008 development blog: http://jezabekgsoc.wordpress.com/
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Post by vitamin »

mikolajz wrote:Winelib allows you to compile a Win32 application to an ELF binary that can be run directly on Linux
No they can't be run directly on Linux. All Wine's programs are winelib (notepad, wordpad, winecfg, etc). Go ahead and run then directly (without Wine).

Again I'm not talking about a binfmt magic with witch you can run even java programs "directly". I'm talking about program depending still Wine.
User avatar
DanKegel
Moderator
Moderator
Posts: 1164
Joined: Wed May 14, 2008 11:44 am

Winelib: How can I compile a Borland C++ Builder application

Post by DanKegel »

mikolajz wrote:
Winelib allows you to compile a Win32 application
to an ELF binary that can be run directly on Linux
(provided the winelib is installed).
Not so. The ELF binary must be run via wine-preloader.

In other words, it's really no more convenient than using
wine on a win32 binary.
- Dan
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Winelib: How can I compile a Borland C++ Builder applica

Post by vitamin »

Néstor Amigo Cairo wrote:There's no problem if I need winelib to link the application, the
important thing is to be able to share the same sources between
platforms, not having to rewrite the API related stuff, but to be able
to debug the application and so on using native tools (not having to
compile under Win32, then trying on Linux + wine).
If that's your goal - you can't use Wine or winelib:
1. You won't get native application
2. You will have to use wine's own debuggin tools (which are still buggy)
3. You can't use Borland specific extensions or anything that's not supported by gcc (most notably exception handling)
4. You will have to recompile VCL with gcc (which won't work)

You have to rewrite your application to something cross-platform. Look at many applications that are available for Linux/Mac/Windows. For example pidgin.

If you want to get your program running now on Linux - just use windows binary and fix Wine if you have any problems.
Locked