顯示具有 Cross_Compile 標籤的文章。 顯示所有文章
顯示具有 Cross_Compile 標籤的文章。 顯示所有文章

2018年1月23日 星期二

 如果沒有build server root 權限且缺少執行檔, 可以直接用下面方法產生執行檔

export PKG_CONFIG_PATH=<your local installation path>/lib/pkgconfig
autoreconf -f -i
./configure –prefix=<your local installation path>
make
make install
     export PATH=[execution file path]:$PATH

2017年12月22日 星期五

GCC: the --start-group and --end-group command line options

https://stackoverflow.com/questions/5651869/gcc-what-are-the-start-group-and-end-group-command-line-options

https://linux.die.net/man/1/ld

-( archives -) or --start-group archives --end-group
The archives should be a list of archive files. They may be either explicit file names, or -l options.
The specified archives are searched repeatedly until no new undefined references are created. Normally, an archive is searched only once in the order that it is specified on the command line. If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference. By grouping the archives, they all be searched repeatedly until all possible references are resolved.
Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives.

2017年12月6日 星期三

link unused library as needed

https://lists.ubuntu.com/archives/ubuntu-devel/2010-November/031991.html

There is a second change to the linking in natty; as announced in [1], 
--no-add-needed/--no-copy-dt-needed-entries is passed by default, with the 
current gcc in natty, --as-needed is passed as well.  Please see [2] for 
implications (runtime failures) and a list of packages which might be affected.

To revert this change on a per package basis, pass --no-as-needed to the linker 
(-Wl,--no-as-needed in LDFLAGS).  To add an explicit dependency on a library use 
--no-as-needed -lfoo --as-needed.
-Wl,--no-as-needed -lfoo -Wl,--as-needed
Please tag bug reports with `as-needed' if you see runtime failures caused by 
this change (mostly unresolvable symbols referenced by plugins and ldopened 
objects).

2017年11月14日 星期二

[轉] 編譯中的-shared和-fPIC

接著昨天的工作,絕大部分問題已經解決,現在拖到最後解決,擺在眼前的問題是:
1makefileLDFLAGS有參數-shared,導致報錯
/usr/bin/ld: md5c.o: relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
md5c.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [object] Error 1
2、去掉在LDFLAGS中添加-fPIC同樣報錯,去掉-shared,有沒有-fPIC都沒有這個報錯了,但是會有另一個報錯
//usr/lib/crt1.o: In function `_start':
(.text+0x34): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [object] Error 1
這表明沒有-shared選項,編譯器預設編譯的是一個可執行程式,但是又找不到main函數(-start是內核程式的主函數,應用程式主函數為main,是供-start調用的),看來,-shared不能去掉

那麼為什麼報錯提示會說recompile with -fPIC呢?
原來,人家說的是“recompilewith -fPIC,而不是用-fPIC連結,所以-fPIC應該添加到CPPFLAGS += -fPIC中,而非LDFLAGS。將mainservicemakefile添上這一行命令,在他用到的所有連結化物件(包括libtinyxml.a)的makefile中都添上,再編譯,就ok了。


2017年10月29日 星期日

configure “--prefix” option for cross compiling

https://stackoverflow.com/questions/33410423/configure-prefix-option-for-cross-compiling

--prefix is the path for working environment. Just use --prefix=/usr. You can check in which folder path make install command will install your binary by installing in DESTDIR. For example if you use --prefix=/usr and make install DESTDIR=/home/me/arm/build/target_fs, then the binaries will be installed in the folder /home/me/arm/build/target_fs/usr. And If you just run make install, then the binary will be installed in your prefix i.e. in "/usr".



Cross-compile: How to install with one prefix, and deploy with a different prefix?

https://stackoverflow.com/questions/6078086/cross-compile-how-to-install-with-one-prefix-and-deploy-with-a-different-prefi

  • configure will certainly do some sed in file, so you need to specify the final place
    ./configure --prefix=/ CC=[my-cross-compiler-gcc]
  • makefile generated by automake have support of variable DESTDIR which is prepended to the installation path:
    make DESTDIR=/var/install install