差異處
這裏顯示兩個版本的差異處。
下次修改 | 前次修改 | ||
gcc [2017/11/05 02:29] jz 建立 |
gcc [2017/11/12 23:02] (目前版本) jz |
||
---|---|---|---|
行 1: | 行 1: | ||
- | ====== gcc ====== | + | ====== GCC ====== |
- | ===== Distinguish ELF Binary is Hard-float / Soft-float ===== | + | ===== Compile ===== |
+ | <code bash> | ||
+ | g++ mylib1.cpp | ||
+ | g++ mylib2.cpp | ||
+ | |||
+ | # shared | ||
+ | g++ -shared -fPIC -o libmylib.so mylib1.o mylib2.o | ||
+ | g++ -o main main.cpp libmylib.so | ||
+ | LD_LIBRARY_PATH=. ./main | ||
+ | |||
+ | # static | ||
+ | ar rcs libmylib.a mylib1.o mylib2.o | ||
+ | g++ -o main main.cpp -L. lmylib | ||
+ | ./main | ||
+ | |||
+ | # prevents linking with the shared libraries | ||
+ | g++ -static -o main main.cpp -L. lmylib | ||
+ | </code> | ||
+ | |||
+ | ===== Distinguish An ELF Binary is Hard-float or Soft-float ===== | ||
<code> | <code> | ||
行 22: | 行 41: | ||
[[https://www.linaro.org/downloads/]] | [[https://www.linaro.org/downloads/]] | ||
+ | |||
+ | |||
+ | **Ref** | ||
+ | * http://codingstandards.iteye.com/blog/1142358 | ||
+ | * https://www.ptt.cc/bbs/LinuxDev/M.1162669989.A.2E6.html |