我正在尝试在OSDev GCC Cross-Compiler Tutuorial.之后在Ubuntu 上为i686-elf设置交叉编译器。但是,设置GCC的代码每次都无法构建。我知道我的来源并没有过时,因为我sudo apt-get update
之前做过任何事情。
为了获得我需要的包裹,我做了:
sudo apt-get install g++
sudo apt-get install make
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install libgmp3-dev
sudo apt-get install libmpfr-dev libmpfr-doc libmpfr4 libmpfr4-dbg
sudo apt-get install mpc
sudo apt-get install texinfo
sudo apt-get install libcloog-isl-dev
我认为该方法没有问题?
然后,使用 gcc-5.2.0 和 binutils-2.25.1 (在ubuntu中,bintuils似乎无法使用旧版本之上的任何内容)我安装了binutils正好。我去构建gcc但是当我输入make时,我收到以下错误:
很遗憾,我无法复制+粘贴30页,但所有代码都接近结尾:
checking command to parse nm output from gcc -m32 object... failed
checking how to run the C preprocessor... /lib/cpp
checking for ANSI C header files... no
checking for sys/types.h... no
checking for sys/stat.h... no
checking for stdlib.h... no
checking for string.h... no
checking for memory.h... no
checking for strings.h... no
checking for inttypes.h... no
checking for stdint.h... no
checking for unistd.h... no
checking for dlfcn.h... no
checking for objdir... .libs
checking if gcc -m32 supports -fno-rtti -fno-exceptions... no
checking for gcc -m32 option to produce PIC... -fPIC -DPIC
checking if gcc -m32 PIC flag -fPIC -DPIC works... yes
checking if gcc -m32 static flag -static works... no
checking if gcc -m32 supports -c -o file.o... yes
checking if gcc -m32 supports -c -o file.o... (cached) yes
checking whether the gcc -m32 linker (ld -m elf_x86_64 -m elf_i386) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
Makefile:9590: recipe for target 'configure-zlib' failed
make[1]: *** [configure-zlib] Error 1
make[1]: Leaving directory '/home/david/scr'
Makefile:876: recipe for target 'all' failed
make: *** [all] Error 2
这是发生了一些非常糟糕事情的部分(就在那之后):
checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
Makefile:9590: recipe for target 'configure-zlib' failed
make[1]: *** [configure-zlib] Error 1
make[1]: Leaving directory '/home/david/scr'
Makefile:876: recipe for target 'all' failed
make: *** [all] Error 2
任何人都可以告诉我我做错了什么以及如何解决它?
谢谢!
答案 0 :(得分:1)
除了--with-system-zlib
之外,当我使用--disable-multilib
选项时,它对我有用。
答案 1 :(得分:1)
问题在于我没有从源代码安装mpc。
这是完成的文件(####################################
echo Stage 1 - Building Dependencies
####################################
# make a working directory
cd $HOME/Documents
rm -rf Cross
mkdir Cross
cd Cross
# install or update all apt-get dependencies
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc # not cross
sudo apt-get install g++
sudo apt-get install make
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install gawk
sudo apt-get install libgmp3-dev
sudo apt-get install libmpfr-dev libmpfr-doc libmpfr4 libmpfr4-dbg
sudo apt-get install mpc
sudo apt-get install texinfo # optional
sudo apt-get install libcloog-isl-dev # optional
sudo apt-get install build-essential
sudo apt-get install glibc-devel
sudo apt-get -y install gcc-multilib libc6-i386
# download and unpack necessary files
wget http://ftpmirror.gnu.org/binutils/binutils-2.25.1.tar.gz
wget http://ftpmirror.gnu.org/gcc/gcc-5.3.0/gcc-5.3.0.tar.gz
wget http://ftpmirror.gnu.org/mpc/mpc-1.0.3.tar.gz
for f in *.tar*; do tar zvxf $f; done
# create installation directory
mkdir Install
export PREFIX="$HOME/Documents/Cross/Install"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"
################################
echo Stage 2 - Building Compiler
################################
# install mpc
mkdir build-mpc
cd build-mpc
../mpc-1.0.3/configure --prefix="$PREFIX"
make -j2
make -j2 check
make -j2 install
cd ..
# install binutils
mkdir build-binutils
cd build-binutils
../binutils-2.25.1/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make -j2
make -j2 install
cd ..
# install gcc
mkdir build-gcc
cd build-gcc
../gcc-5.3.0/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers --with-mpc="$PREFIX"
make -j2 all-gcc
make -j2 all-target-libgcc
make -j2 install-gcc
make -j2 install-target-libgcc
):
export PREFIX="$HOME/Documents/Cross/Install"
export TARGET=i686-elf
$PREFIX/bin/$TARGET-gcc --version
安装完成后,您可以使用以下命令运行它:
$HOME/Documents/Cross directory.
不幸的是,在别名或bash脚本中执行此操作似乎无法正确启动它,因此,除非得到修复,否则您可能只需将脚本存储在文本文件中并将其复制粘贴到每次重启时终端。
要卸载交叉编译器,只需删除$PREFIX
最后一点,更改安装目录或目标就像更改$TARGET
或@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService myUserService;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(myUserService);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/resources/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.rememberMe()
.alwaysRemember(true)
.and()
.logout()
.permitAll();
}
}
的值一样简单,但我不推荐它,因为您可能遇到其他意想不到的问题。