Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

SNAP how to use dynamic linker ldconfig or LD_LIBRARY_PATH

SNAP how to use dynamic linker ldconfig or LD_LIBRARY_PATH

schwebo
Established Member

Good Morning,

i have a applikation /binary which i want to pack to a SNAP. I setup a Linux VM on my PC (amd64).

to execute my app directly i have to setup the dynamic-runtime linker in order to copy my own config file with lib pathes to

cp myConfigFileWithPathes.conf /etc/ld.so.conf.d/
ldconfig

after thas.  i can create a SNAP on my VM target ,  and i can this snap...

So my question:

But how can i do this for a SNAP on a xCtrl Hardware? How can i setup my snapcraft, that the dynamic linker pathes will autmatice setup according to the target!?  I read about the $LD_CONFIG_PATH

I tried so something like that in my app in the snap yaml (but it does not work)

environment:
LD_LIBRARY_PATH: $LD_LIBRARY_PATH:my_pathes_from_the_config_file
 
But wenn i build the snap i still get the followed warnings: (but this libs normal resolve from the dynamic link in the conf file)
 
This part is missing libraries that cannot be satisfied with any available stage-packages known to snapcraft:
- home/xctrlvm/AppEngine/drivers/halcon/libhalcon.so.20.11.1
- home/xctrlvm/AppEngine/drivers/halcon/libhalconc.so.20.11.1
- home/xctrlvm/AppEngine/drivers/halcon/libhalconcpp.so.20.11.1
- home/xctrlvm/AppEngine/drivers/halcon/libhdevenginecpp.so.20.11.1
- home/xctrlvm/AppEngine/libeuler_log_frontend.so.1
- home/xctrlvm/AppEngine/libeuler_plugin_loader.so.1
4 REPLIES 4

nickH
Community Moderator
Community Moderator

Hello, 

some topics from my side:

  • Did you setup your Development Environment with one of the two options we recommend in the SDK Docu on GitHub?
  • Please have a look into the SDK and see how the sample snaps for ctrlX CORE in the different programming languages get build.
  • For detailed information on how to build a snap see: snapcraft - creating a snap  

 

I'm sorry, but I didn't understand everything from your post. Can you please explain your issue and your desired snap build process a little bit deeper (maybe also share your snapcraft.yaml)? 

Best regards,

Nick

 

 

schwebo
Established Member

Good morning nick,

thank for response. I'll try to explany it clearer.

First, i setup a VM with sdk and so on, and iam able to build the sample-snaps form the sdk. until then everything is fine:) 

Second, i am a noob in Linux and SNAP, but i try to learn this technologies and do my best.

I have a application binary-builds for Linux arm64 and amd64. An i can run this appilcation in my linux VM whitout SNAP. To get the applikation running, i have to copy a .conf (from my app) file to the /etc/ld.so.conf.d/ folder which contians lib-path from my app. And with ldconfig i announce the dynamic linker of linux that ther are new lib locations... than i can execute my app from the cli .

Now, i want to pack my Application to a SNAP. So, my first though, create a snapcraft with a app and and  part (plugin:dump) with the source of my binary (which mention above). the problem ist now, that the SNAP build process has to the same which i have done above for the dynamic-linker. So is read soming about the LD_PATH_LIBRARY. to provide dynamic-linker path something like this:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/path/to1/:$SNAP/path/to2/:$SNAP/path/to3/"

but how can i to that with SNAP implcity!?

 

So i understand, is the a .snap file which is build, contains ALL Libs which are needed, that meand the lib from the dynanamic.linker are alos copies to the snap file !?!?!?!

 

Thank you

nickH
Community Moderator
Community Moderator

Hello, 

Just to show some basics about snaps I copied out an extract from the snapcraft.yaml of the hello.world sample from the SDK and added some comments: 

 

# define how apps & services are exposed to host system
apps:
  HelloWorld:                            #name of your application (binary build)  
    command: HelloWorld          #this will be the command to run the service
    plugs:                                    #plugs to connect to interfaces
      - network
    daemon: simple                     #declares that your application gets started by the system deamon
    passthrough:                          #restarts the application if it shuts down after 10 sec
      restart-condition: always             
      restart-delay: 10s  

#describes how the binary application (from folder ./generated/build) gets packed (dumped) into the snap 
parts:
  helloworld:
    plugin: dump
    source: ./generated/build

 

 Please a look into the snpacraft.yaml reference. It describes all the details snapcraft needs to build a snap. 

 


@schwebo wrote:

So i understand, is the a .snap file which is build, contains ALL Libs which are needed, that meand the lib from the dynanamic.linker are alos copies to the snap file !?!?!?!


Yes, this is true. Snaps in general are self contained and therefor have to have all needed dependencies inside.

I hope I could clarify some things. You can share your snapcraft.yaml (with some comments) so we can have a look at your snap build mechanism. 

JohannesA
Established Member

Hi 

maybe you are looking for "stage-packages" ? 

JohannesA_0-1649411488403.png

 

If you have to add own libraries you can dump it into the snap using the dump plugin.

$SNAP/lib:$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu (on amd64 architecture) are default part of the LD_LIBRARY_PATH

If you add your library to another directory within your snap you have to extend the environment variable e.g.:

apps:
example-app:
 [...]
 environment:
    LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/<example-directory>

 

Regards

Johannes

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist