sazr
sazr

Reputation: 25928

Copy Linux Application to another Linux OS

I am new to developing Embedded C++ programs on Linux. I have my Debian OS where I have developed and compiled my C++ project (a simple console process).

I want to get my application onto another Debian OS (a base station OS). I am connected to this OS via SSH and USB connection.

How can I copy my application onto the base station Debian OS? Should I use SSH? What files do I need to copy? Is it just the my_application file that I need to copy or do I need to copy the .so and/or .o files? I hope I don't need to create a .deb file?

Upvotes: 0

Views: 2053

Answers (1)

Michael Jaros
Michael Jaros

Reputation: 4681

OK, this is a huge topic, I can just try to give you some basic information. Search the web for more, there are lots of tutorials and articles, e.g. this one.

Creating a .deb package would be the recommended way for a production system. Otherwise you will have to keep track of the installed version, any dependencies, and config files yourself.

If you are just playing around, you will be fine if you just copy the executable (and any libraries that are not on the system yet), e.g. to ~/bin in your base station user's home directory.

You can find out shared library (.so) dependencies of your executable using ldd. You need all of these on the target system too. Usually you should just install the respective library packages (use dpkg -S on a filename to learn which package it belongs to):

ldd ./myprogram

If you have to add custom libraries that you can't install via the package manager, you copy the .so files to the same directory as your program and then modify LD_LIBRARY_PATH on execution:

`LD_LIBRARY_PATH="$LD_LIBRARY_PATH":. ./myprogram

You don't have to copy .o files as they are linked into your executable already.

You can use scp to copy files to your base station, but you'll probably have to log in and create the target directory ~/bin first:

scp /path/to/somefile myuser@mybasestation:~/bin/

It should be noted that ~/bin is not where you usually install your shared libraries.

Upvotes: 2

Related Questions