Вы находитесь на странице: 1из 8

1

SDK
x86 toolchain




Revision History
Rev Date Author Description
V0.10 19/Oct/2010 Kent Tsai Initial draft




2


Content
1 Introduction ................................................................................................................................................ 3
2 Install the x86 toolchain .............................................................................................................................. 4
3 Test if hello world worked in x86 platform .............................................................................................. 5
4 Cross-compiling and testing your application ............................................................................................. 6
4.1 Cross-compiling your application ...................................................................................................... 6
4.2 Testing the binary of your application ............................................................................................... 6
4.3 Running your own application at startup .......................................................................................... 6
5 Additional libraries ...................................................................................................................................... 7
6 Important Notes ......................................................................................................................................... 8


3

1 Introduction
This document provides detailed description to create the cross compile environment and
build your application for QNAP NAS. It also provides how to run your own application at
startup in QNAP NAS system.



4

2 Install the x86 toolchain
Please follow the steps to install/uninstall toolchain on your host Linux machine

To Install:
As root, decompress the toolchain to the / folder
tar zxvf cross-project-x86.u7-20101019.tar.gz -C /

To Uninstall:
As root, remove /opt/cross-project/x86
rm rf /opt/cross-project/x86

5

3 Test if hello world worked in x86 platform
Please follow the steps to test hello world program
A. chroot /opt/cross-project/x86/sys-root
B. cd /src/hello_world_project
C. gcc -o hello_world hello_world.c
D. scp hello_world admin@xxx.xxx.xxx.xxx:/root (xxx.xxx.xxx.xxx is your NAS IP)
E. ssh admin@xxx.xxx.xxx.xxx /root/hello_world (xxx.xxx.xxx.xxx is your NAS IP)
(It works if you can see the output Hello World!!)

6

4 Cross-compiling and testing your application
4.1 Cross-compiling your application
Please follow the steps
A. Put your project in /opt/cross-project/x86/sys-root/src/myproject
B. chroot /opt/cross-project/x86/sys-root
C. cd /src/myproject
D. use gcc or make to compile your project
4.2 Testing the binary of your application
Please follow the steps
A. scp your_binary admin@xxx.xxx.xxx.xxx:/root
B. Use ssh to login to your NAS
C. Run your_binary (./your_binary)
4.3 Running your own application at startup
Please follow the steps
A. scp your_binary admin@xxx.xxx.xxx.xxx:/root
B. Use ssh to login to your NAS
C. mount -t ext2 /dev/sdx6 /tmp/config
D. cp /root/your_binary /tmp/config
E. create your own autorun.sh script in /tmp/config/autorun.sh
F. chown +x /tmp/config/autorun.sh
G. umount /tmp/config
Note: you can also refer to QNAP wiki to make your autorun.sh script
http://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup




7

5 Additional libraries
If you are going to cross-compile some packages, they might miss some libraries. Get the
libraries source code first, and follow standard procedure to compile/install it.

For example, to compile libpng, follow the steps
A. Download libpng source to /opt/cross-project/x86/sys-root/src (wget
http://prdownloads.sourceforge.net/libpng/libpng-1.4.4.tar.gz?download)
B. chroot /opt/cross-project/x86/sys-root
C. cd /src
D. tar zxvf libpng-1.4.4.tar.gz
E. cd libpng-1.4.4
F. ./configure
G. make
H. make install




8

6 Important Notes
Question:
When I use scp to upload binary to NAS, the ram disk is full, how can I do?
Answer:
Change the target directory to hard disk
ex: scp your_binary admin@xxx.xxx.xxx.xxx:/mnt/HDA_ROOT
scp your_binary admin@xxx.xxx.xxx.xxx:/share/MD0_DATA

Question:
The log of my application will cause ram disk full, how can I don?
Answer:
Usually open source or application might save logs, to prevent ram disk full, always make
sure the log file has been size rotated or save it to hard disks
(Ram disk full will cause your system abnormal and unstable)

Вам также может понравиться