|
On 11/05/17 00:04, Charles Steinkuehler
wrote:
I proposed a patch ages ago in Linuxcnc and Jeff eventually wrote in his own version to comp, but it has been there a long while.On 5/10/2017 5:06 PM, Brian Schousek wrote:I am writing an RT component that depends on an external library external.so.Is there a cleaner way to tell instcomp to link with external.so and thus be able to take advantage of instcomp --compile and --install switches as well?For a regular component I use: EXTRA_LDFLAGS="-lexternal" comp --compile mycomp.comp ...that will probably work with instcomp as well. So there is an undocumented 'feature' in comp which allows the defining of a library when building user-space components. https://github.com/machinekit/machinekit/blob/master/src/hal/utils/comp.g#L659 for instance: extra_link_args = "-L/usr/local/lib/specials -lspecial" When writing instcomp this feature was not carried over for simplicity and to prevent the linking of completely inappropriate libraries. instantiated component instances may be userland, but they are not userspace per se, so are still subject to the timing constraints of RT components in many ways and the last thing you want is blocking code or sleep() being imported for instance. * Therefore the method that Charles outlines is probably the best for actual HAL components. * If you want to interface with HAL in other than a simple component loaded through halcmd, I personally find it far easier to write a Qt C++ userspace program that does it. Others may prefer different languages, but the principle is the same. You then have all the advantages of access to Machinekit internals, plus the power and ease of use of all the basic C/C++ libraries plus GUI libraries if required. There are only a few calls required to register with the running Machinekit instance. ``` char prefix[] = "testapp"; // This single call inserts the component into the running system comp_id = hal_init(prefix); if(comp_id < 0) { rtapi_print_msg(RTAPI_MSG_ERR,"Error hal_init failed with error code %d", comp_id); exit(comp_id); } ....... // do stuff, create pins etc. hal_ready(comp_id); ``` // then you need a loop mechanism or event driven callback to do your work within the program, update etc etc. regards -- website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit --- You received this message because you are subscribed to the Google Groups "Machinekit" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/machinekit. For more options, visit https://groups.google.com/d/optout. |
- [Machinekit] How to link external library throug... Brian Schousek
- Re: [Machinekit] How to link external libra... Charles Steinkuehler
- Re: [Machinekit] How to link external l... [email protected]
