Makefile 如何在/usr/lib中对库进行tcc搜索?

Makefile 如何在/usr/lib中对库进行tcc搜索?,makefile,configure,tcc,Makefile,Configure,Tcc,在我的Raspberry PI计算机上,我从源代码(in/usr/local/src)编译了tcc编译器。当我链接到/usr/lib中的库时,tcc找不到它,所以我需要在tcc命令中添加-L/usr/lib。如何配置并使tcc在其库路径中包含/usr/lib pi@raspberrypi /usr/local/src/tcc-0.9.26 $ tcc -vv tcc version 0.9.26 (ARM Hard Float Linux) install: /usr/local/lib/tcc

在我的Raspberry PI计算机上,我从源代码(in/usr/local/src)编译了tcc编译器。当我链接到/usr/lib中的库时,tcc找不到它,所以我需要在tcc命令中添加-L/usr/lib。如何配置并使tcc在其库路径中包含/usr/lib

pi@raspberrypi /usr/local/src/tcc-0.9.26 $ tcc -vv
tcc version 0.9.26 (ARM Hard Float Linux)
install: /usr/local/lib/tcc/
crt:
  /usr/lib/arm-linux-gnueabihf
libraries:
  /usr/lib/arm-linux-gnueabihf
  /lib/arm-linux-gnueabihf
  /usr/local/lib/arm-linux-gnueabihf
include:
  /usr/local/include
  /usr/local/include/arm-linux-gnueabihf
  /usr/include
  /usr/include/arm-linux-gnueabihf
  /usr/local/lib/tcc/include
elfinterp:
  /lib/ld-linux-armhf.so.3

这是编译tcc本身时的配置选项。如果要使用二进制tcc分布,则必须继续使用-L选项

然而,自己编译tcc应该很容易。这些是粗略的步骤:

% git clone git://repo.or.cz/tinycc.git 
% cd tinycc 
% ./configure --libpaths=/usr/lib
% make
还有更多的选择。见:

% ./configure --help
Usage: configure [options]
Options: [defaults in brackets after descriptions]

Standard options:
  --help                   print this message
  --prefix=PREFIX          install in PREFIX [/usr/local]
  --exec-prefix=EPREFIX    install architecture-dependent files in EPREFIX
                           [same as prefix]
  --bindir=DIR             user executables in DIR [EPREFIX/bin]
  --libdir=DIR             object code libraries in DIR [EPREFIX/lib]
  --tccdir=DIR             installation directory [EPREFIX/lib/tcc]
  --includedir=DIR         C header files in DIR [PREFIX/include]
  --sharedir=DIR           documentation root DIR [PREFIX/share]
  --docdir=DIR             documentation in DIR [SHAREDIR/doc/tcc]
  --mandir=DIR             man documentation in DIR [SHAREDIR/man]
  --infodir=DIR            info documentation in DIR [SHAREDIR/info]

Advanced options (experts only):
  --source-path=PATH       path of source code [/Users/miki/projects/tinycc-so]
  --cross-prefix=PREFIX    use PREFIX for compile tools []
  --sysroot=PREFIX         prepend PREFIX to library/include paths []
  --cc=CC                  use C compiler CC [gcc]
  --extra-cflags=          specify compiler flags [-Wall -g -O2]
  --extra-ldflags=         specify linker options []
  --strip-binaries         strip symbol tables from resulting binaries
  --disable-static         make libtcc.so instead of libtcc.a
  --disable-rpath          disable use of -rpath with the above
  --with-libgcc            use /lib/libgcc_s.so.1 instead of libtcc.a
  --enable-mingw32         build windows version on linux with mingw32
  --enable-cygwin          build windows version on windows with cygwin
  --enable-cross           build cross compilers
  --enable-assert          enable debug assertions
  --with-selinux           use mmap for exec mem [needs writable /tmp]
  --sysincludepaths=...    specify system include paths, colon separated
  --libpaths=...           specify system library paths, colon separated
  --crtprefix=...          specify locations of crt?.o, colon separated
  --elfinterp=...          specify elf interpreter
您可能还希望将tcc安装到配置的目录中

% make install

这是编译tcc本身时的配置选项。如果要使用二进制tcc分布,则必须继续使用-L选项

然而,自己编译tcc应该很容易。这些是粗略的步骤:

% git clone git://repo.or.cz/tinycc.git 
% cd tinycc 
% ./configure --libpaths=/usr/lib
% make
还有更多的选择。见:

% ./configure --help
Usage: configure [options]
Options: [defaults in brackets after descriptions]

Standard options:
  --help                   print this message
  --prefix=PREFIX          install in PREFIX [/usr/local]
  --exec-prefix=EPREFIX    install architecture-dependent files in EPREFIX
                           [same as prefix]
  --bindir=DIR             user executables in DIR [EPREFIX/bin]
  --libdir=DIR             object code libraries in DIR [EPREFIX/lib]
  --tccdir=DIR             installation directory [EPREFIX/lib/tcc]
  --includedir=DIR         C header files in DIR [PREFIX/include]
  --sharedir=DIR           documentation root DIR [PREFIX/share]
  --docdir=DIR             documentation in DIR [SHAREDIR/doc/tcc]
  --mandir=DIR             man documentation in DIR [SHAREDIR/man]
  --infodir=DIR            info documentation in DIR [SHAREDIR/info]

Advanced options (experts only):
  --source-path=PATH       path of source code [/Users/miki/projects/tinycc-so]
  --cross-prefix=PREFIX    use PREFIX for compile tools []
  --sysroot=PREFIX         prepend PREFIX to library/include paths []
  --cc=CC                  use C compiler CC [gcc]
  --extra-cflags=          specify compiler flags [-Wall -g -O2]
  --extra-ldflags=         specify linker options []
  --strip-binaries         strip symbol tables from resulting binaries
  --disable-static         make libtcc.so instead of libtcc.a
  --disable-rpath          disable use of -rpath with the above
  --with-libgcc            use /lib/libgcc_s.so.1 instead of libtcc.a
  --enable-mingw32         build windows version on linux with mingw32
  --enable-cygwin          build windows version on windows with cygwin
  --enable-cross           build cross compilers
  --enable-assert          enable debug assertions
  --with-selinux           use mmap for exec mem [needs writable /tmp]
  --sysincludepaths=...    specify system include paths, colon separated
  --libpaths=...           specify system library paths, colon separated
  --crtprefix=...          specify locations of crt?.o, colon separated
  --elfinterp=...          specify elf interpreter
您可能还希望将tcc安装到配置的目录中

% make install

事实证明,我们需要使用
libpath
选项,还需要指定默认的库目录(从
tcc-vv
输出)。我们还可以添加标准目录
/lib
/usr/local/lib

# ./configure --libpaths=/usr/local/lib/arm-linux-gnueabihf:/lib/arm-linux-gnueabihf:/usr/lib/arm-linux-gnueabihf:/usr/local/lib:/lib:/usr/lib

事实证明,我们需要使用
libpath
选项,还需要指定默认的库目录(从
tcc-vv
输出)。我们还可以添加标准目录
/lib
/usr/local/lib

# ./configure --libpaths=/usr/local/lib/arm-linux-gnueabihf:/lib/arm-linux-gnueabihf:/usr/lib/arm-linux-gnueabihf:/usr/local/lib:/lib:/usr/lib

据我所知,设置
--libdir
这种方式将/usr/local/lib替换为/usr/lib。我想做的是将/usr/lib添加到库搜索路径。即使我使用
--libdir=/usr/lib
进行配置,我仍然需要-L选项,并且从
tcc-vv
获得相同的输出。我很抱歉。参数应该是--libpath,而不是--libdir。它们确实有不同的含义。我已经相应地更正了我的答案。不幸的是,设置libpath也不起作用。当我运行
make test
时,第一个测试失败,出现“undefined symbol'\uu libc\u csu\u fini'”。据我所知,设置
--libdir
这种方式将/usr/local/lib替换为/usr/lib。我想做的是将/usr/lib添加到库搜索路径。即使我使用
--libdir=/usr/lib
进行配置,我仍然需要-L选项,并且从
tcc-vv
获得相同的输出。我很抱歉。参数应该是--libpath,而不是--libdir。它们确实有不同的含义。我已经相应地更正了我的答案。不幸的是,设置libpath也不起作用。当我运行
make test
时,第一个测试失败,出现“未定义的符号'\uuu libc\u csu\u fini'”。