c - 如何解决“链接器命令失败,退出代码 1”问题?
问题描述
我正在尝试使用OMPTrace
哪个工具来跟踪和可视化OpenMP
程序执行,如此处所示https://github.com/passlab/omptrace。示例中给出的代码是用C
. (jacobi.c
和axpy.c
)该库已很好地安装在/home/hakim/llvm-openmp/BUILD/omptrace/build/libomptrace.so
. 我创建了一个makefile
如下:
OMP_INSTALL=/home/hakim/llvm-openmp-install
OMP_LIB_PATH=${OMP_INSTALL}/lib
OMPTRACE_LIB=/home/hakim/llvm-openmp/BUILD/omptrace/build/libomptrace.so
default:runaxpy
axpyclang: axpy.c
clang -g -fopenmp axpy.c -o axpyclang
objdump -d axpyclang >axpyclang.objdump
jacobi: jacobi.c
clang -g -fopenmp jacobi.c -o jacobi -lm
objdump -d jacobi >jacobi.objdump
runaxpy: axpyclang
LD_PRELOAD=${OMP_LIB_PATH}/libomp.so:${OMPTRACE_LIB} ./axpyclang 1024
runjacobi: jacobi
LD_PRELOAD=${OMP_LIB_PATH}/libomp.so:${OMPTRACE_LIB} ./jacobi
clean:
rm axpyclang axpyclang.objdump core jacobi jacobi.objdump
执行它时,我得到:
clang -g -fopenmp axpy.c -o axpyclang
axpy.c:18:5: warning: 'ftime' is deprecated [-Wdeprecated-declarations]
ftime(&tm);
^
/usr/include/x86_64-linux-gnu/sys/timeb.h:40:19: note: 'ftime' has been explicitly marked deprecated here
__nonnull ((1)) __attribute_deprecated__;
^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:251:51: note: expanded from macro '__attribute_deprecated__'
# define __attribute_deprecated__ __attribute__ ((__deprecated__))
^
axpy.c:25:5: warning: 'ftime' is deprecated [-Wdeprecated-declarations]
ftime(&tm);
^
/usr/include/x86_64-linux-gnu/sys/timeb.h:40:19: note: 'ftime' has been explicitly marked deprecated here
__nonnull ((1)) __attribute_deprecated__;
^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:251:51: note: expanded from macro '__attribute_deprecated__'
# define __attribute_deprecated__ __attribute__ ((__deprecated__))
^
axpy.c:95:5: warning: implicit declaration of function 'sleep' is invalid in C99 [-Wimplicit-function-declaration]
sleep(1);
^
3 warnings generated.
/usr/bin/ld: cannot find -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [makefile:8: axpyclang] Error 1
真正困扰我的是,我在 3 小时前成功执行了 makefile 并生成了一个graphml
文件,但现在,我收到了新的多重警告 + 一个错误。我想知道它是否来自clang
编译器(版本 10.0.0-4ubuntu1),因为收到新警告让我觉得我可能更新了编译器(但忘记了)。
请问有什么帮助吗?
解决方案
- 您需要找到 libomp.a
- 将 libomp.a 所在的路径添加到
ld
命令行参数中-Lpath
- 请享用
推荐阅读
- flutter - 根据字符串值改变颜色
- python - import pandas as pd ModuleNotFoundError: No module named 'pandas'
- prolog - PROLOG 自行车旅行任务,创建规则和查询
- javascript - 将小写字符串与未更改的对象键匹配
- angular - ng run project:deploy - 项目目标不存在
- python - 如何将列表元素转置/分离到熊猫数据框列中
- ios - 需要 UITableViewCell 内的 UICollectionView 具有动态高度
- flutter - 将照片放在屏幕顶部
- python - 如何使用python创建谷歌图像幻灯片
- javascript - Mongoose,在值上创建随机字符串的正确方法