GCC

来自bbxwiki
跳转至: 导航搜索

R_X86_64_32 & could not read symbols

  • 编译加上"-fPIC"


configure时设置fPIC

  • ./configure CPPFLAGS=-fPIC --prefix=... --with-x=...
  • 编译Debug版本 CFLAGS="-g -O0" ./configure


configure、make后修改安装目录

  • DESTDIR=/whereto make install


configrue,make,make install出错

  • 问题:undefined reference to `__sync_fetch_and_add_4'
    • ./configure --disable-64bit CFLAGS="-O3 -march=i686"
  • 问题:
    • ...


error: gnu/stubs-32.h: 没有那个文件或目录

  • Redhat/CentOS yum install glic-devel.i686


GCC编译安装

  • 依次安装三个依赖gmp, mpfr, mpc (configure, make, make install)
    • ../gmp-5.1.3/configure --prefix=/usr/local/gmp-5.1.3
    • ../mpfr-3.1.2/configure --prefix=/usr/local/mpfr-3.1.2 --with-gmp=/usr/local/gmp-5.1.3
    • ../mpc-1.0.1/configure --prefix=/usr/local/mpc-1.0.1 --with-gmp=/usr/local/gmp-5.1.3 --with-mpfr=/usr/local/mpfr-3.1.2
  • configure选项
../gcc-4.3.4/configure --prefix=/usr/local/gcc-4.3.4 --with-gmp=/usr/local/gmp-5.1.3 --with-mpfr=/usr/local/mpfr-3.1.2 --with-mpc=/usr/local/mpc-1.0.1 
   --enable-shared --enable-threads=posix --with-system-zlib --enable-languages=c,c++ --with-cpu=generic --enable--long-long --disable-checking
export LD_LIBRARY_PATH=.:/usr/local/gmp-5.1.3/lib:/usr/local/gmp-5.1.3/lib:/usr/local/mpfr-3.1.2/lib
make


unicode编译选项

  • -fshort-wchar将Unicode的大小调整为2个字节
  • -fwide-exec-charset=charset 将编译后的ELF文件unicode类型,可取值为:UTF-16LE, UTF-16BE


源码、可执行文件字符集

  • -finput-charset=charset 指定源码字符集
  • -fexec-charset=charset 指定ELF文件中字符集


include路径

C_INCLUDE_PATH(for C header files)和CPLUS_INCLUDE_PATH(for C++ header files)的环境变量是指明头文件的搜索路径,此两个环境变量指明的头文件会在-I指定路径之后,系统默认路径之前进行搜索。

LIBRARY_PATH指明库搜索路径,此环境变量指明路径会在-L指定路径之后,系统默认路径之前被搜索。


todo

  • 1
  • 2
  • 3