使用openMP交叉编译到ARM-linux时出错

时间:2015-12-31 16:37:14

标签: linux arm openmp cross-compiling

我尝试使用OpenMP for ARM Linux交叉编译程序。 当我将-fopenmp标志添加到编译链时,我收到以下错误:

arm-xilinx-linux-gnueabi-gcc: error: libgomp.spec: No such file or directory

我不确定编译器应该在哪里查找此文件。在libgomp.spec上使用locate显示:

locate libgomp.spec
/home/Xilinx/Vivado_HLS/2014.4/lnx32/tools/gcc/lib/libgomp.spec
/usr/lib/gcc/i686-linux-gnu/4.7/libgomp.spec
/usr/lib/gcc/i686-linux-gnu/4.8/libgomp.spec
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/libgomp.spec

我应该将此文件移动到其他路径吗?它应该在哪里?

1 个答案:

答案 0 :(得分:1)

我也在调查这个问题。查看arm-xilinx-linux-gnueabi-gcc本身的配置选项,似乎libgomp已使用--disable-libgomp停用:

$ arm-xilinx-linux-gnueabi-gcc -v
- Using built-in specs.
- COLLECT_GCC=arm-xilinx-linux-gnueabi-gcc
- COLLECT_LTO_WRAPPER=/opt/Xilinx/SDK/2015.2/gnu/arm/lin/bin/../libexec/gcc/arm-xilinx-linux-gnueabi/4.9.1/lto-wrapper
- Target: arm-xilinx-linux-gnueabi
- Configured with:
  /scratch/cltang/xilinx/linux/src/gcc-4.9-2014.11/configure
  --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu
  --target=arm-xilinx-linux-gnueabi --enable-threads
  ...
  --disable-libgomp --disable-libitm --enable-libatomic
  --disable-libssp --enable-poison-system-directories
- Thread model: posix
- gcc version 4.9.1 (Sourcery CodeBench Lite 2014.11-30) 

我们需要在启用此配置的情况下获得arm-linux-gnueabi编译器,或者自己进行交叉编译。

<强> [编辑]

从发行版存储库安装arm-linux-gnueabi-gcc。在我的案例中,XUbuntu 14.04:

sudo apt-get install gcc-arm-linux-gnueabi
查看其规范(libgomp)时,

arm-linux-gnueabi-gcc -v未显示为已停用。

从PetaLinux使用的Makefile生成示例hello.c应用程序时需要进行以下更改。请注意使用-static来避免与libgopt共享对象的动态链接,仅在主机中可用。

# <petalinux_project>/components/apps/hello/Makefile


ifndef PETALINUX
$(error "Error: PETALINUX environment variable not set.  Change to the root of your PetaLinux install, and source the settings.sh file")
endif

include apps.common.mk

APP = hello

# Add any other object files to this list below
APP_OBJS = hello.o

all: build install

build: $(APP)

## -> + Replaced: $(CC) with arm-linux-gnueabi-gcc
## -> + Added: -fopenmp -static
$(APP): $(APP_OBJS)
    arm-linux-gnueabi-gcc $(LDFLAGS) -fopenmp -static -o $@ $(APP_OBJS) $(LDLIBS)

clean:
    -rm -f $(APP) *.elf *.gdb *.o

.PHONY: install image

install: $(APP)
    $(TARGETINST) -d $(APP) /bin/$(APP)

## -> + Replaced: $(CC) with arm-linux-gnueabi-gcc
## -> + Added: -fopenmp 
%.o: %.c
    arm-linux-gnueabi-gcc -c $(CFLAGS)  -fopenmp -o $@ $<

help:
    @echo ""
    @echo "Quick reference for various supported build targets for $(INSTANCE)."
    @echo "----------------------------------------------------"
    @echo "  clean                  clean out build objects"
    @echo "  all                    build $(INSTANCE) and install to rootfs host copy"
    @echo "  build                  build subsystem"
    @echo "  install                install built objects to rootfs host copy"

为完整起见,以下是hello.c示例代码:

/*
 * Placeholder PetaLinux user application.
 *
 * Replace this with your application code
 */
#include <stdio.h>
#include <omp.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("Hello, PetaLinux World!\n");
    printf("cmdline args:\n");
    while(argc--)
        printf("%s\n",*argv++);


#pragma omp parallel
        printf("Hello from thread %d, nthreads %d\n",
               omp_get_thread_num(),
               omp_get_num_threads());
    return 0;
}

最后,来自PetaLinux框架的构建和jtag传输:

<petalinux_project>$ petalinux-build -v -c rootfs/hello
<petalinux_project>$ petalinux-build -x package
<petalinux_project>$ petalinux-boot --jtag --fpga --bitstream pre-built/linux/implementation/download.bit --u-boot --kernel