Recent

Author Topic: Linking LCL in GCC  (Read 8341 times)

Jedive

  • Newbie
  • Posts: 3
Linking LCL in GCC
« on: May 13, 2014, 02:54:21 pm »
Hello everyone.

I would like to use LCL into a C++ application. I am writing my own procedural wrapper, to export LCL classes as a set of functions usable within C, and I am trying to link it into my executable. Everything works if I build a dll within Lazarus and use that, but I would like to link the library statically.

Using the ar tool I have built a static library from the .o files generated by Lazarus. When I link the library in my C++ application, I get many unresolved external symbols, like: FPC_LIBINITIALIZEUNITS, FPC_LIB_EXIT, FPC_RESSYMBOL, _CLASSES_TCOMPONENT_$__EXECUTEACTION$TBASICACTION$$BOOLEAN, etc.

I guess that I need to link to RTL, LCL and LCLBase, but I don't know where these libraries are in the Lazarus installation. Are they static .a libraries, or are they a set of .o files? If you could point me to where these compiled libraries are, it would be of much help.

Thanks in advance.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Linking LCL in GCC
« Reply #1 on: May 13, 2014, 03:33:08 pm »
I would like to use LCL into a C++ application.

I don't have answers for your questions, sorry, but I am curious why you want to do this?
There are loads of C++ libraries available, including GUI libs. Usually people want to use C libraries from Pascal code because Pascal is easier and less error prone.
« Last Edit: May 13, 2014, 08:27:22 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Jedive

  • Newbie
  • Posts: 3
Re: Linking LCL in GCC
« Reply #2 on: May 13, 2014, 03:45:57 pm »
Because Qt is too big, bloated, and a hell to redistribute (too many dependencies). GTK+ does not look "native" enough on Windows and OS X, and I had some problems with the last version wxWidgets on OS X (apart that I tried that lib some time ago and didn't like it too much).

LCL seemed perfect for my needs, except that I want to use it in C++. I already have exported some components as a dll and have sucessfully used them in C++, but now I want to statically link it.

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Linking LCL in GCC
« Reply #3 on: May 13, 2014, 05:20:59 pm »
Your best option is export all the required libs in pure c, and link the library in pascal. You will find awesome speed in time required for code. With flexibility of LCL. I guess currently you are in wrong direction, it will only waste your valuable time.

Happy coding :-)
Holiday season is online now. :-)

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: Linking LCL in GCC
« Reply #4 on: May 13, 2014, 05:34:19 pm »
Take a look at this blog post: https://blog.benny-baumann.de/?p=1565
It is in german, but by looking at code and console output you can guess what this means

P.S.: http://stackoverflow.com/questions/22770389/create-a-statically-linkable-library-in-freepascal
"call FPC_INITIALIZEUNITS on startup and FPC_FINALIZEUNITS on shutdown."
« Last Edit: May 13, 2014, 05:37:08 pm by hinst »
Too late to escape fate

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11455
  • FPC developer.
Re: Linking LCL in GCC
« Reply #5 on: May 13, 2014, 08:13:10 pm »
1. No readily made .a's.
2. A FPC program is  (a) startup code (b) compiler generated code for the main program (or library unit) (c) other units.

The FPC_INITIALIZE_UNITS is part of (b). Roughly the easiest way I assume is to try to link everything Pascal into a DLL. I'm not aware of sb trying though

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Linking LCL in GCC
« Reply #6 on: May 17, 2014, 06:56:13 am »
Because Qt is too big, bloated, and a hell to redistribute (too many dependencies). GTK+ does not look "native" enough on Windows and OS X, and I had some problems with the last version wxWidgets on OS X (apart that I tried that lib some time ago and didn't like it too much).
LCL is just a wrapper for one of those libs (depending on what you choose), unless you use fpGUI backend. But that backend is far from complete, compared to others. So you will eventually need one of those libs installed as well.

Jedive

  • Newbie
  • Posts: 3
Re: Linking LCL in GCC
« Reply #7 on: May 19, 2014, 11:46:18 am »
LCL is just a wrapper for one of those libs (depending on what you choose), unless you use fpGUI backend. But that backend is far from complete, compared to others. So you will eventually need one of those libs installed as well.
AFAIK, LCL requires GTK+ on Linux, which is Ok, but on Windows it uses the Win32 API and on OS X it uses Carbon.

I think I'll take the dll route by now, since linking with LCL statically seems to be way more difficult than I initially thought. Thank you all for your answers.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Linking LCL in GCC
« Reply #8 on: May 19, 2014, 05:06:05 pm »
Quote
AFAIK, LCL requires GTK+ on Linux, which is Ok, but on Windows it uses the Win32 API and on OS X it uses Carbon.
Correction: it requires whatever backend is chosen, regardless the OS (of course the backend itself must be supported by the OS). GTK+ and Qt can be used on all supported OSes, Win32 API is Windows only and Carbon/Cocoa is OS X only.

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Linking LCL in GCC
« Reply #9 on: May 19, 2014, 07:54:10 pm »
AFAIK, LCL requires GTK+ on Linux, which is Ok, but on Windows it uses the Win32 API and on OS X it uses Carbon.
Requires for what? Requires for compile or for running?
COmpilation:
Lazarus also support of cross-widget-compile. Meaning you can compile for QT while your lazarus is built using GTK in Windows.
http://forum.lazarus.freepascal.org/index.php/topic,24578.msg148064.html#msg148064
The only true IMHO is : GDI always required by Lazarus in Windows (run & compiles). Otherwise, we can cross-OS-compile + cross widget compile.


While the requirement of debugging:
App's OS = Lazarus OS
App's Widgetset = arready installed. No similar as Lazrus widget required for debug time.
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Linking LCL in GCC
« Reply #10 on: May 19, 2014, 07:56:49 pm »
Oops, the cross-widgetset-compile configuration is here: http://forum.lazarus.freepascal.org/index.php/topic,24578.msg148086.html#msg148086
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

 

TinyPortal © 2005-2018