Wednesday, September 5, 2018

android load native dll dlopen failed . Undefined Reference to __atomic_* . __atomic_exchange_4

reference to: https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md

Some ABIs (particularly armeabi) need libatomic to provide some implementations for atomic operations.

The case was arm64 works,  armeabi had exception . 
dlopen failed,  Undefined Reference to __atomic_exchange_4

Solution: Add -latomic when linking.

The solution not working, since the -latomic already in link flag.

reference to :

https://github.com/android-ndk/ndk/issues/589

Just FYI, we were running into the same issue. In our case it was not enough to add -latomic to the linker option, but -latomic had to be listed as the last option, even after the C++ standard library.

So the added -Wl -latomic fix the issue.  

Thursday, March 8, 2018

Backslash escape in Ubuntu and MySQL export data from command line

I need write a bash script to export data from mysql.
The below command ran got good results in mysql shell.

Select [datacolum] from [table] into outfile 'outputfile'  FIELDS TERMINATED BY ',' ESCAPED BY '\\' LINES TERMINATED BY '\r\n';

And I ran it in command line:

mysql -u user -ppassword database <<EOF
Select [datacolum] from [table] into outfile 'outputfile'  FIELDS TERMINATED BY ',' ESCAPED BY '\\' LINES TERMINATED BY '\r\n';
EOF

I got exception :

ERROR 1049 (42000) at line 1: Unknown database 'n';'

Finally I realized:

The backslash escape in Ubuntu:

root@ubuntu:~# echo '\'
\
root@ubuntu:~# echo "'\'"
'\'
root@ubuntu:~# echo '\\'
\\
root@ubuntu:~# echo "'\\'"
'\'

So the correct ran the above sql in command line should be:

mysql -u user -ppassword database <<EOF
Select [datacolum] from [table] into outfile 'outputfile'  FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' LINES TERMINATED BY '\r\n';
EOF





Monday, February 5, 2018

Sed -i change the text start with space

I met a issue that want use sed to replace a line start with space. and new line also start with space.

Just like new line want keep indentation as before.

replaced="    def"
sed -i "/  abc/c   $replaced" temp.txt

in this case ,   the new line will lost the space ,  no indentation

The way to do it :

replaced="\    def"
sed -i "/  abc/c   $replaced" temp.txt

This will keep space after the replacement.