Raspberry Pi 13: How to perform cross-compilation with wiringPi library

How to carry out cross-compilation with wiringPi library

1. Normally, we need to cross-compile the wiringPi library first. The compiled library is suitable for Raspberry Pi. At this time, when cross-compiling executable programs, the format of the link library is also correct.
2. Specify by -I -L

However, errors often occur because there is no way to cross compile the wiringPi library.

We need to use the wiringPi library of the Raspberry Pi.

Type in the Raspberry Pi terminal:

cd /usr/lib
ls

Insert picture description here
Migrate this file from Raspberry Pi to Linux operating system:

cd /usr/lib
ls

Insert picture description here
The above problems occur.

First we need to install ssh on Linux and enable ssh service

su -
在root权限下:
//安装
sudo apt-get install openssh-server
//开启服务
service sshd start

This process reference:
Linux install ssh and open ssh service

Then solve the problem that the root account of Ubuntu cannot log in to SSH-Permission denied, please try again

Insert picture description here
The reason is that the root user is prohibited from logging in to ssh by default. At this time, we can solve it like this:

su -
给予root权限
gedit  /etc/ssh/sshd_config
//进行修改

重启服务
systemctl restart sshd.service

Modified resultInsert picture description here

Reference for this process:
Solve the problem that the root account of Ubuntu cannot log in to SSH-Permission denied, please try again

—Another more earthy way is to use FileZilla:

Insert picture description here
To assist in the transfer of files.

Linux create connection command ln -s to create soft connection

ln -s is a very important command in Linux, you must be familiar with it. Its function is to establish a same link for a certain file in another location. The most commonly used parameter of this command is -s,

Soft connection : (symbolic connection)

1. Soft link files have shortcuts similar to Windows. It is actually a special file.
2. In the soft link, the file is actually a text file, which contains the location information of another file.
3. It will only generate a mirror image of a file on the location you selected, and will not take up disk space

Hard connection :
1. Hard connection refers to the connection through the index node. In the Linux file system, no matter what type of file is stored in a disk partition, a number is assigned to it, which is called an inode index. In Linux, multiple file names point to the same index node. Generally this kind of connection is a hard connection.
2. Without the parameter -s, it will generate a file with the same size as the source file at the location you selected. Whether it is a soft link or a hard link, the file will keep changing in sync

//具体用法是:ln -s 源文件 目标文件。
ln -s libwiringPi.so.2.50 libwiringPi.so
ls
ls -l

Insert picture description here

Reference article:
Linux create connection command ln -s to create a soft connection

//交叉编译
arm-linux-gnueabihf-gcc demo2.c -I /home/dazai/WiringPi/wiringPi -L. -lwiringPi
//可执行文件复制到树莓派
scp crosscompbindemo2.c pi@192.168.1.100:/home/pi

The Raspberry Pi has finished running.

Guess you like

Origin blog.csdn.net/weixin_40734514/article/details/108714616