Tag Archives: linux

Failed to dlsym make_device: undefined symbol: make_device

Failed to dlsym make_ device: undefined symbol: make_ device

Recently, I encountered some bugs when doing development. I have been troubled for a long time. Although I am a good cook, I think I can accumulate it. When I encounter the same type of problems in the future, I have a way to solve the problems. The problem is as follows: Android recovery system can do some basic test demo below. But this latest demo is developed by C + + and C language. Some functions need to rely on dynamic libraries, such as librecovery_ UI. So, but there is a special library called librecovery_ ui.recovery.so。 At that time, using the find command, we could find the generation location of the library. However, when using grep to find the generation location of the dynamic library, we couldn’t find it. We only found the calling location. For a time, we doubted whether we had made a mistake. Finally, we searched under the general system root directory. Finally, we kept printing a lot of messy code under the out subdirectory, thinking it was a program crash, It’s time for ^ C to end the process. But in the end, no matter how many, just let it collapse. Finally, we found the location of the Library under the out directory. It turned out that it was an automatically generated MK file, in which many concise generation dependent library scripts were used. Finally, we found the location of the so.

Then I met the problem on the topic, that is, how can the so library compiled according to the correct android.mk script file not find the defined library when using dlopen call?I wonder if there is a problem with the function, and then I wrote a new function to test the call, and found it still can’t work, Failed to dlsym FN: undefined symbol: test is also displayed. Then I searched the Internet and found that most people said that they needed to add extern “C” to the function. Finally, according to what I said on the Internet, I found that it was still not possible. Finally, I asked my colleagues and got the answer to the question, which is to use the nm command of Linux to find the dynamic library or the static library that contains the functions that can be called. Finally, I found that the dynamic library that I passed to the board did not have the make that I wanted to call_ Then use the find command to find two. So libraries with the same name. Finally, find the function body to be called in another library. Finally, transfer another. So library to the board. Finally, it is successful.

Brief introduction of Linux MMAP and solution of bus error

Bus error occurs when mMAP Shared memory is used for communication between unrelated processes. 

Introduction to MMap communication mechanism
About the mmap

Mmap maps a file or other object into memory. A file is mapped to multiple pages, and if the file size is not the sum of all pages, the unused space of the last page is cleared. Munmap does the opposite, removing the object map for a specific address area.
When mmap is used to map the file to the process, the virtual address can be directly operated for file reading and writing operations, and there is no need to call read,write and other system calls. Note, however, that writing directly to this segment of memory does not write anything larger than the current file size.

An obvious benefit of using Shared memory communication is efficiency,
Because the process can read and write directly to memory without any copy of the data. For communications such as pipes and message queues, there are four copies of the data in the kernel and user space, and only two copies of the data in Shared memory: once from the input file to the Shared memory area, and once from the Shared memory area to the output file. In fact, when processes share memory, they do not always unmap after reading and writing a small amount of data, and re-establish the Shared memory area when there is new communication. Instead, the Shared area is kept until the communication is complete, so that the data content is kept in Shared memory and not written back to the file. Content in Shared memory is often written back to the file when the map is unmapped. Therefore, using the Shared memory communication method is very efficient.

Introduction to the MMAP function

Void * START, size_t length, int PROt,int FD, OFF_t offset);

Parameter description:

Start: The start address of the mapping area.
length: the length of the desired mapping area.
prot: the desired memory protection flag cannot conflict with the open mode of the file. Is one of the following values that can be reasonably combined by an OR operation.
 PROT_EXEC// pages can be executed
 PROT_READ/page/content can be read
 PROT_WRITE// page can be written to the
 PROT_NONE // page not accessible

flags: specifies the type of mapping object, mapping options, and whether the mapping page can be Shared. Its value can be a combination of one or more of the following bits. MAP_SHARED is generally used.
MAP_SHARED// Shared with all the process of mapping the object mapping space. Writes to a Shared area, equivalent to output to a file. The file is not actually updated until either Msync () or Munmap () is invoked.

fd: valid file description. If MAP_ANONYMOUS is set, the value should be -1 for compatibility issues.
offset: offset of the mapped object content (generally 0).

 

Bus Error solution

After mMAP, when the memory copy is made, the write() function is first used to write to the file descriptor that has been opened.

 

Reference code

Write:

<span style="font-size:12px;">// Arthur: zhangxiao
// Data: 2014/12/24	
// Note: mmap write
/*******************/

#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
//#define FILENAME "/home/zhangxiao/embededSystem/example/Mmap/test"

#define FILENAME "/tmp/test"
#define BUFLEN 128	
typedef struct
{
	char name[BUFLEN];
	int  id;
}people;

int main(int argc, char** argv) 
{
	int i;
	unsigned int pmap=0;
	int fd;
	fd=open(FILENAME ,O_CREAT|O_RDWR|O_TRUNC,00777 );
	assert(fd !=-1);
	pmap = (unsigned int)mmap(0,sizeof(people),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
	assert(pmap!=-1);
	write(fd," ",sizeof(people)); //write something
	unsigned int addr;
	addr=pmap;
	char tempname[30]="helloworld";
	int tempid=253; 
	addr = pmap + sizeof(char)*BUFLEN;	
	memcpy((void *)pmap,tempname,strlen(tempname)+1);
	memcpy((void *)addr, &tempid,sizeof(int));
	munmap((void *) pmap,sizeof(char)*BUFLEN);
	close(fd);
	printf("umap ok\r\n");
	return 0;
}</span><strong style="color: rgb(255, 0, 0); font-size: 19px;">
</strong>

Read:

// Arthur: zhangxiao
// Data: 2014/12/24	
// Note: mmap read 
/*******************/
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
//#define FILENAME "/home/zhangxiao/embededSystem/example/Mmap/test"
#define FILENAME "/tmp/test"
#define BUFLEN 128	
typedef struct
{
	char name[BUFLEN];
	int  id;
}people;

int main(int argc, char** argv) 
{
	int i;
	unsigned int pmap=0;
	int fd;
	fd=open(FILENAME ,O_CREAT|O_RDWR,00777 );
	assert(fd !=-1);
	pmap = (unsigned int)mmap(0,sizeof(people),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
	unsigned int addr;
	addr = pmap + sizeof(char)*BUFLEN;	
	printf("id=%d   name=%s\n\r",*((int *)addr),(char *)pmap);	
	munmap((void *) pmap,sizeof(char)*BUFLEN);
	close(fd);
	printf("umap ok\r\n");
	return 0;
}

 

Makefile:

CROSS = gcc

flags=-o
all:mmap_read mmap_write

mmap_read:mmap_read.c
	$(CROSS) $(flags) mmap_read mmap_read.c
mmap_write:mmap_write.c
	$(CROSS) $(flags) mmap_write mmap_write.c

clean:
	rm -rf mmap_read mmap_write<strong>
</strong>

 

How to Solve “Error: source file could not be loaded“ [Ubuntu Use LibreOffice]

#Accident scene

Use libreoffice under Ubuntu to convert txt to PDF. The command is as follows:

libreoffice  --invisible --convert-to pdf   /home/parasaga/resource/testtxt.txt --outdir /home/parasaga/resource/

report errors:

Error: source file could not be loaded

#Causes and Solutions

1. Reason:

To install libreoffice, use the following command:

sudo apt-get install libreoffice-common

In this way, the libreoffice writer module will not be installed, resulting in the above error;

2. Solution:

Install the libreoffice writer module.

sudo apt-get install libreoffice-writer

httpd Run Error: Job for httpd.service failed because the control process exited with error code.

Job for httpd.service failed because the control process exited with error code.
See “systemctl status httpd.service” and “journalctl -xe” for details.

When opening the httpd service, the error as shown in the title appears

 

# systemctl start httpd.service

Job for httpd.service failed because the control process exited with error code.
See "systemctl status httpd.service" and "journalctl -xe" for details.

View the startup log through systemctl status

Check whether port 80 is occupied

netstat -antlp | grep 80

Killing process with kill instruction

Input the httpd start command again, and the error still exists.

Finally, it is found that the & lt; Directory/> It is found that the access permission of the/usr directory is readable by anyone but not executable. Therefore, the access permission of the/usr directory is changed

chmod -R o+x /usr

Try to open the service again, success!

to update:

Configuration of httpd.conf

ERROR: KeeperErrorCode = NoNode for /hbase/master

Error: keepererrorcode = nonode for/HBase/master error occurred when inputting command in HBase shell

Error screenshot:

solution:
solution 1: close zookeeper, delete the version-2 folder under your own dataDir path, and then restart (used)
solution 2: add a paragraph in hbase-site.xml

<property>
	<name>hbase.unsafe.stream.capability.enforce</name>
	<value>false</value>
</property>

The method can be used for the purpose of applying a tube, and for the purpose of this problem, I would like to say that there are three things: Core site HDFS site HBase site HBase. Rootdir . Plan 5: we have a large amount of disambiguation ( *) cause: namede on namespaceid and datanode It was found that the number of nodes under the nodal de nodal de nodal de paceme was not significant. The first language resolution method is: dfs.datanode. Data. Dir in dandoop Hadoop S>

The second edition disambiguation method: clusterid in data under current/current versioning.

subprocess installed post-installation script returned error exit status 1

If apt-get has the error “Script returned error exit status 1 after subprocess install”
dpkg:error handling util-linux (-configure):
Script returned error exit status 1 after subprocess install
An error was encountered while processing:
util-linux
E:Subprocess /usr/bin/dpkg returned error code (1)
Go to /var/lib/dpkg/info directory
Delete the stuck package file
apt-get autoclean
apt-get autoremove
apt-get update
apt-get upgrade

How to open X Display on the server side (locally operable remote interface)

The problem is this:
processes some photos on the server, and sometimes you want to look directly at the images on the server. But the server is Ubuntu Server, with no graphical interface. If we use feH, or cv2.imshow(), the error will be reported as follows:
Feh ERROR: Can’t open X display. It is running, yeah?
Solutions:
It should be in the server side ~/.bashrc file

export DISPLAY=localhost=10.0
On the server side the /etc/ssh/ssh_config file should be set to :

Host *
ForwardX11 yes

Use the following parameters when sshing to the server.
ssh -CAXY your-server-name@your-server-ip

Solution to IO error encountered in Rsync: skipping file deletion

Previously it was synchronous:

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1650) [generator=3.1.2]

So I add the r and force parameters to the sync script.

# cat mirrors.sh
#!/bin/bash
###End an existing rsync process
killall `ps aux|grep rsync|awk -F" " '{print $11}'`
killall `ps aux|grep rsync|awk -F" " '{print $11}'`
echo Ending time `date +%F_%H%M%S`                                  >> /tmp/rsync_process.log
echo '###################Ending time ######################' >> /tmp/rsync_process.log
#http://mirrors.ustc.edu.cn/help/rsync-guide.html
URL="rsync://mirrors.tuna.tsinghua.edu.cn"
#URL="rsync://rsync.mirrors.ustc.edu.cn/repo"
rsync -ravzPH --delete  --force                $URL/centos/ /data/centos/ >> /tmp/rsync_centos.log 
rsync -ravzPH --delete  --force                $URL/epel/   /data/epel    >> /tmp/rsync_epel.log   
#rsync -avzPH --delete                  $URL/ceph/ /data/ceph >> /tmp/rsync_ceph.log
echo Completion time `date +%F_%H%M%S`                                  >> /tmp/rsync_process.log
echo '###################Completion time ######################' >> /tmp/rsync_process.log

IO error and blade file deletion appeared synchronously

[root@mirrors tmp]# tail -f rsync_centos.log
|   Service Provided by                            |
|      neomirrors                                  |
|                                                  |
+==================================================+

 Note: This service is provided with a modified
 version of rsync. For detailed information, please
 visit: https://github.com/tuna/rsync

receiving incremental file list
IO error encountered -- skipping file deletion

Meanwhile another error still exists:

rsync: readlink_stat("7.7.1908/isos/x86_64/.CentOS-7-x86_64-Everything-1908.iso.RjFDl5" (in centos)) failed: Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1650) [generator=3.1.2]

Taking a closer look at the parameters of rsync, one of the options is:
Delete even if I/O errors occur
(Delete even if I/O error occurs)

[root@mirrors bin]# cat mirrors.sh
#!/bin/bash
###End an existing rsync process
killall `ps aux|grep rsync|awk -F" " '{print $11}'`
killall `ps aux|grep rsync|awk -F" " '{print $11}'`
echo Ending time `date +%F_%H%M%S`                                  >> /tmp/rsync_process.log
echo '###################Ending time ######################' >> /tmp/rsync_process.log
#http://mirrors.ustc.edu.cn/help/rsync-guide.html
URL="rsync://mirrors.tuna.tsinghua.edu.cn"
#URL="rsync://rsync.mirrors.ustc.edu.cn/repo"
rsync -ravzPH --delete  --force   --ignore-errors             $URL/centos/ /data/centos/ >> /tmp/rsync_centos.log 
rsync -ravzPH --delete  --force   --ignore-errors             $URL/epel/   /data/epel    >> /tmp/rsync_epel.log   
#rsync -avzPH --delete                  $URL/ceph/ /data/ceph >> /tmp/rsync_ceph.log
echo Completion time `date +%F_%H%M%S`                                  >> /tmp/rsync_process.log
echo '###################Completion time ######################' >> /tmp/rsync_process.log

OK, so far there is no error.

Shell Script syntax error near unexpected token `done’

1. Modify the file type
Vi finddir.sh enter: set ff If fileformat= DOS, change to Unix: : set FF = Unix execute save command: : WQ
2. Delete hidden characters
Open your SHELL script file with the command VI-b, and you will. It is found that there is an extra ^M at the end of each line of the script because MS-DOS and Windows are return + line feed to represent line feed. Therefore, Vim is used in Linux to view the code written in Windows with VC. The “^M” symbol at the end of the line represents the character.
To eliminate “^M” in Vim with the substitution function, type the following substitution command line: 1) vi-b setup.sh2) on the command edit line
< That is: press ESC and shift: colon >
Note: the “M” character on the command line above is not “” and” M “, but is generated by “Ctrl V” and “Ctrl M”. After this substitution, the save is ready to be executed.