[Lazarus] Building a C (or possibly C++) program into a Lazarus app

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Building a C (or possibly C++) program into a Lazarus app

Free Pascal - Lazarus mailing list
Is it possible to link a C or possibly C++ program into a Lazarus one by
simply calling its main() function? Has anybody actually done this?

I've got a couple of C/C++ programs which are based on stdin/stdout user
interaction (no curses etc.) but have thoroughly unpleasant keyboard
requirements and odd output encoding. I find myself wondering whether
they could be given a more friendly frontend by wrapping them in a
Lazarus app, with an on-screen keyboard similar to what's found on a
tablet etc.

I would, obviously, be able to rename main() if necessary, as well as
I/O functions.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Building a C (or possibly C++) program into a Lazarus app

Free Pascal - Lazarus mailing list
I have some posts on the forum asking about similar questions. I was
told FPC object files will link just fine with GNU tools, so you
should be able to.

To me it seemed it would be easier to keep the codebase in C++ but
then call into the LCL. Sadly that is quite a bit off.

On Fri, Aug 10, 2018 at 9:44 AM, Mark Morgan Lloyd via Lazarus
<[hidden email]> wrote:

> Is it possible to link a C or possibly C++ program into a Lazarus one by
> simply calling its main() function? Has anybody actually done this?
>
> I've got a couple of C/C++ programs which are based on stdin/stdout user
> interaction (no curses etc.) but have thoroughly unpleasant keyboard
> requirements and odd output encoding. I find myself wondering whether they
> could be given a more friendly frontend by wrapping them in a Lazarus app,
> with an on-screen keyboard similar to what's found on a tablet etc.
>
> I would, obviously, be able to rename main() if necessary, as well as I/O
> functions.
>
> --
> Mark Morgan Lloyd
> markMLl .AT. telemetry.co .DOT. uk
>
> [Opinions above are the author's, not those of his employers or colleagues]
> --
> _______________________________________________
> Lazarus mailing list
> [hidden email]
> https://lists.lazarus-ide.org/listinfo/lazarus
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Building a C (or possibly C++) program into a Lazarus app

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
> I find myself wondering whether
> they could be given a more friendly frontend by wrapping them in a
> Lazarus app, with an on-screen keyboard similar to what's found on a
> tablet etc.

Sounds like my non-web hobby projects with Lazarus.

> Is it possible to link a C or possibly C++ program into a Lazarus one by
> simply calling its main() function? Has anybody actually done this?

I don't do that, though. Even if technically possible, there are hidden
stuffs you have to be aware of. main() is only a specification in C
standard, where the user code starts. However, long before that, there's a
startup mechanism specific to each implementation. In GCC, this is _start,
absolutely non-portable. That's why the IMO better way is to communicate
over pipes via TProcess.



--
Sent from: http://free-pascal-lazarus.989080.n3.nabble.com/
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Building a C (or possibly C++) program into a Lazarus app

Free Pascal - Lazarus mailing list
On 10/08/18 20:45, leledumbo via Lazarus wrote:
>> I find myself wondering whether > they could be given a more friendly frontend by wrapping them in a > Lazarus app, with an on-screen keyboard similar to what's found on a > tablet etc.
> Sounds like my non-web hobby projects with Lazarus.
>> Is it possible to link a C or possibly C++ program into a Lazarus one by > simply calling its main() function? Has anybody actually done this?
> I don't do that, though. Even if technically possible, there are hiddenstuffs you have to be aware of. main() is only a specification in Cstandard, where the user code starts. However, long before that, there's astartup mechanism specific to each implementation. In GCC, this is _start,absolutely non-portable. That's why the IMO better way is to communicateover pipes via TProcess.

Thanks for that. The program I'm thinking about is actually pretty
simple and ancient- written by Ken Thompson- so I might be in with a chance.

What I'd /really/ like to do is port it- complete with UI helper- to
Android. However at that point I have to add my voice to Bo's plea of a
couple of weeks ago: what's the current situation and future plans of
Lazarus as far as Android is concerned? I see mention of Laz4Android in
e.g. http://wiki.lazarus.freepascal.org/Android_tutorial : is that
mainstream or is there some other preferred solution?

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Building a C (or possibly C++) program into a Lazarus app

Free Pascal - Lazarus mailing list
> what's the current situation and future plans of
> Lazarus as far as Android is concerned? I see mention of Laz4Android in
> e.g. http://wiki.lazarus.freepascal.org/Android_tutorial : is that
> mainstream or is there some other preferred solution?

Laz4Android is just a prepackaged Lazarus  + FPC + Android NDK. You can
create Android apps using Custom Drawn Interface, but it's very incomplete
and non-native. I don't see any better way than LAMW right now, at least
it's maintained, progressing, user requests are handled (quite fast), rather
complete (just look at the demos, I don't think you need more than already
provided components for most apps) and use native look and feel.



--
Sent from: http://free-pascal-lazarus.989080.n3.nabble.com/
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Building a C (or possibly C++) program into a Lazarus app

Free Pascal - Lazarus mailing list
On 12/08/18 20:00, leledumbo via Lazarus wrote:
>> what's the current situation and future plans of > Lazarus as far as Android is concerned? I see mention of Laz4Android in > e.g. http://wiki.lazarus.freepascal.org/Android_tutorial : is that > mainstream or is there some other preferred solution?
> Laz4Android is just a prepackaged Lazarus  + FPC + Android NDK. You cancreate Android apps using Custom Drawn Interface, but it's very incompleteand non-native. I don't see any better way than LAMW right now, at leastit's maintained, progressing, user requests are handled (quite fast), rathercomplete (just look at the demos, I don't think you need more than alreadyprovided components for most apps) and use native look and feel.

TFT, I'll investigate.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus