Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-06

Using Lazarus to build a (Linux) shared library, with a form

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

I'm struggling here. I can build a trivial (empty) .so using Lazarus 1.1+2.6.0, the only necessary manual operation being to tell the project options to remove the (Windows-specific?) -Wr option. I can load the result at runtime, although I've not so far put significant code into it.

As soon as use Lazarus to add a form to the project, it no longer loads. In order to find out what's going wrong I've had to use dlerror(), i.e. bypassing the dynlibs library since it doesn't have a function e.g. GetLoadErrorStr(). This shows me that the low-level dlopen() is complaining "undefined symbol: WSRegisterCustomImageList".

What do I have to manually add to the project to get this working?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Sven Barth
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 13 lines
I'm struggling here. I can build a trivial (empty) .so using Lazarus 1.1+2.6.0, the only necessary manual operation being to tell the project options to remove the (Windows-specific?) -Wr option. I can load the result at runtime, although I've not so far put significant code into it. As soon as use Lazarus to add a form to the project, it no longer loads. In order to find out what's going wrong I've had to use dlerror(), i.e. bypassing the dynlibs library since it doesn't have a function e.g. GetLoadErrorStr(). This shows me that the low-level dlopen() is complaining "undefined symbol: WSRegisterCustomImageList". What do I have to manually add to the project to get this working?

Estimated guess: add unit "interfaces" to your library project file.

Regards,
Sven

Reply by email

Mark Morgan Lloyd
to Sven Barth
Sven Barth wrote 16 lines
Am 11.06.2012 11:38, schrieb Mark Morgan Lloyd: > I'm struggling here. I can build a trivial (empty) .so using Lazarus > 1.1+2.6.0, the only necessary manual operation being to tell the project > options to remove the (Windows-specific?) -Wr option. I can load the > result at runtime, although I've not so far put significant code into it. > > As soon as use Lazarus to add a form to the project, it no longer loads. > In order to find out what's going wrong I've had to use dlerror(), i.e. > bypassing the dynlibs library since it doesn't have a function e.g. > GetLoadErrorStr(). This shows me that the low-level dlopen() is > complaining "undefined symbol: WSRegisterCustomImageList". > > What do I have to manually add to the project to get this working? > Estimated guess: add unit "interfaces" to your library project file.

Thanks Sven, that does indeed fix it :-)

I was very much at the point of wanting to ask people who knew what they were doing, rather than flail around digging myself into a deeper hole.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Sven Barth
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 24 lines
Sven Barth wrote: > Am 11.06.2012 11:38, schrieb Mark Morgan Lloyd: >> I'm struggling here. I can build a trivial (empty) .so using Lazarus >> 1.1+2.6.0, the only necessary manual operation being to tell the project >> options to remove the (Windows-specific?) -Wr option. I can load the >> result at runtime, although I've not so far put significant code into >> it. >> >> As soon as use Lazarus to add a form to the project, it no longer loads. >> In order to find out what's going wrong I've had to use dlerror(), i.e. >> bypassing the dynlibs library since it doesn't have a function e.g. >> GetLoadErrorStr(). This shows me that the low-level dlopen() is >> complaining "undefined symbol: WSRegisterCustomImageList". >> >> What do I have to manually add to the project to get this working? >> > > Estimated guess: add unit "interfaces" to your library project file. Thanks Sven, that does indeed fix it :-) I was very much at the point of wanting to ask people who knew what they were doing, rather than flail around digging myself into a deeper hole.

Well... regarding the LCL you should keep in mind that you always need the widgetset implementation and that is provided by the unit "Interfaces". So you need to include that unit in every binary (program, library) were you want to use LCL controls.

Regards,
Sven

Reply by email

Mark Morgan Lloyd
to Sven Barth
Sven Barth wrote 32 lines
Am 11.06.2012 12:34, schrieb Mark Morgan Lloyd: > Sven Barth wrote: >> Am 11.06.2012 11:38, schrieb Mark Morgan Lloyd: >>> I'm struggling here. I can build a trivial (empty) .so using Lazarus >>> 1.1+2.6.0, the only necessary manual operation being to tell the >>> project >>> options to remove the (Windows-specific?) -Wr option. I can load the >>> result at runtime, although I've not so far put significant code into >>> it. >>> >>> As soon as use Lazarus to add a form to the project, it no longer >>> loads. >>> In order to find out what's going wrong I've had to use dlerror(), i.e. >>> bypassing the dynlibs library since it doesn't have a function e.g. >>> GetLoadErrorStr(). This shows me that the low-level dlopen() is >>> complaining "undefined symbol: WSRegisterCustomImageList". >>> >>> What do I have to manually add to the project to get this working? >>> >> >> Estimated guess: add unit "interfaces" to your library project file. > > Thanks Sven, that does indeed fix it :-) > > I was very much at the point of wanting to ask people who knew what they > were doing, rather than flail around digging myself into a deeper hole. > Well... regarding the LCL you should keep in mind that you always need the widgetset implementation and that is provided by the unit "Interfaces". So you need to include that unit in every binary (program, library) were you want to use LCL controls.

It's something I should have spotted, and probably would have done if I'd done a file-by-file comparison of the frontend (main program) and backend (shared library). But I've also been floundering through other issues over the weekend- for example whether the build leaves the .so in lib/i386-linux or copies it to the project directory, whether the path was being honoured when I was loading the library, whether I had to run ldconfig etc.- and it was time to try to eliminate unknowns by asking rather than doing.

Anyway, I'm now at the position where I can load the most-recently-created backend, and query "about" information. I'm now moving on to putting some entries in the backend's form's menu, and seeing if I can move them to the frontend.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Mark Morgan Lloyd
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 30 lines
Sven Barth wrote: > Am 11.06.2012 12:34, schrieb Mark Morgan Lloyd: >> Sven Barth wrote: >>> Am 11.06.2012 11:38, schrieb Mark Morgan Lloyd: >>>> I'm struggling here. I can build a trivial (empty) .so using Lazarus >>>> 1.1+2.6.0, the only necessary manual operation being to tell the >>>> project >>>> options to remove the (Windows-specific?) -Wr option. I can load the >>>> result at runtime, although I've not so far put significant code into >>>> it. >>>> >>>> As soon as use Lazarus to add a form to the project, it no longer >>>> loads. >>>> In order to find out what's going wrong I've had to use dlerror(), >>>> i.e. >>>> bypassing the dynlibs library since it doesn't have a function e.g. >>>> GetLoadErrorStr(). This shows me that the low-level dlopen() is >>>> complaining "undefined symbol: WSRegisterCustomImageList". >>>> >>>> What do I have to manually add to the project to get this working? >>>> >>> >>> Estimated guess: add unit "interfaces" to your library project file. >> >> Thanks Sven, that does indeed fix it :-) Anyway, I'm now at the position where I can load the most-recently-created backend, and query "about" information. I'm now moving on to putting some entries in the backend's form's menu, and seeing if I can move them to the frontend.

Now working, including displaying dialog(ue)s embedded in the shared library. I'm doing my own deep copy of TMenuItems to avoid parentage problems, and have ducked all consideration of menu glyphs/bitmaps etc.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email