Cannot have HUG as shared library « Thread Started on Mar 14, 2011, 12:27am »
I have been trying to compile a hello world application linked with HUG as a shared library.
I downloaded 'hug_imports.bac', edited it and changed this line:
Code:
CONST HUG_lib$ = "libhug.so"
I renamed hug.bac to libhug.bac, then:
Code:
# bacon -f libhug.bac Starting conversion... done. Starting compilation... done. Program 'libhug.so' ready. (i copied libhug.so to /usr/lib) # ldconfig # # bacon -l hug hello-gui.bac Starting conversion... done. Starting compilation... done. Program 'hello-gui' ready. # ./hello-gui ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
Joined: Apr 2010 Gender: Male Posts: 938 Location: The Hague, The Netherlands Karma: 9
Re: Cannot have HUG as shared library « Reply #1 on Mar 14, 2011, 7:52am »
Good morning,
it seems to me that you are trying to do two things at once. you are importing functions and also linking with the Shared Object at the same time.
So if you use the 'hug_imports' include file, you do not need to link with the hug.so shared object (therefore you can leave its name unchanged in 'hug_imports'.)
# bacon -l hug hello.bac Starting conversion... done. Starting compilation... done. Program 'test2' ready. # ./test2 ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause. #
But anyway, hug_imports.bac now works, so that is fine. What I was aiming to do is reduce the size of the executable, compared with using INCLUDE "hug.bac".
My proxy-setup executable was 115KB, it is now 50KB. That is significant if I write lots of apps with BaCon.
Joined: Apr 2010 Gender: Male Posts: 938 Location: The Hague, The Netherlands Karma: 9
Re: Cannot have HUG as shared library « Reply #4 on Mar 14, 2011, 12:57pm »
Quote:
The problem that still remains is that I tried the above after having tried doing it according to the documentation.
Can you add 'TRAP LOCAL' in the beginning of your program? I bet this will show that the library you have created could not be found, or something like that.
Quote:
There is one line wrong in hug_imports.bac:
Thanks, you are right, I have corrected it.
Quote:
What I was aiming to do is reduce the size of the executable, compared with using INCLUDE "hug.bac".
The upcoming build22 has the possibility to specify the functions needed to be included. Your program above can be rewritten as follows:
Code:
INCLUDE "hug.bac", "WINDOW", "MARK", "ATTACH", "DISPLAY", "INIT"
This also will lead to smaller binaries, with the advantage that you do not need an external HUG library file. Feel free to test it, especially now we're still in beta stage
Re: Cannot have HUG as shared library « Reply #5 on Mar 15, 2011, 12:06am »
Peter, I tried that new technique of appending the HUG names onto the end of INCLUDE "hug.bac", with my proxy-setup program, and ended up with quite a long line and still got errors when try to compile.
I deleted that code, so will have to get back to you later with test results.
Using this new technique, the size of the executable would be bigger than having an external shared library hug.so, wouldn't it?
My proxy-setup stripped executable dropped from 115KB to 50KB by using hug.so, but of course I then have the overhead of hug.so which is 203KB -- but if we end up with lots of BaCon GUI apps in Puppy then that overhead is a good tradeoff.
Joined: Apr 2010 Gender: Male Posts: 938 Location: The Hague, The Netherlands Karma: 9
Re: Cannot have HUG as shared library « Reply #6 on Mar 15, 2011, 6:59am »
Quote:
Using this new technique, the size of the executable would be bigger than having an external shared library hug.so, wouldn't it?
Well, yes, that's true, but then you need the external library also - if you add them up the result will be bigger. Personally I'ld like to have one binary but I guess it is a matter of taste.
Regards Peter
PS I will be traveling again this week and may not be able to respond very fast.
Re: Cannot have HUG as shared library « Reply #7 on Mar 15, 2011, 9:42am »
Peter, I was thinking that if we really take to using BaCon and HUG for our code development in Puppy, then say 20 applications all using hug.so, that would be 200K/20 equals 10KB overhead per application.
Joined: Apr 2010 Gender: Male Posts: 938 Location: The Hague, The Netherlands Karma: 9
Re: Cannot have HUG as shared library « Reply #9 on Mar 16, 2011, 3:44am »
Quote:
So, I will change hug_imports.bac to reference libhug.so, and I will re-upload my BaCon PET package with name change /usr/lib/libhug.so.
You're free to do so, of course; however, this is only needed when you want to link using the '-l' flag with the library. If your program only uses IMPORTS then this is not necessary.
Joined: Apr 2010 Gender: Male Posts: 938 Location: The Hague, The Netherlands Karma: 9
Re: Cannot have HUG as shared library « Reply #10 on Mar 17, 2011, 1:35pm »
Quote:
I tried that new technique of appending the HUG names onto the end of INCLUDE "hug.bac", with my proxy-setup program, and ended up with quite a long line and still got errors when try to compile.
Well, I have added the following line in the beginning of your proxy-setup program: