【问题标题】:Modifying a makefile to include externally compiled objects修改 makefile 以包含外部编译的对象
【发布时间】:2012-02-23 17:23:22
【问题描述】:

我正在尝试修改 Makefile 以包含外部编译的对象,但收到“未定义引用”错误。这是我第一次处理 Makefile - 请温柔一点。

到目前为止我做了什么:

  • 修改 main.c 以包含新的头文件 cudacrack.h
  • 在 cudacrack.h 中定义的 main.c 中添加了对 runCudaImplementation() 的调用
  • 修改了 Makefile.in 文件以包含 cudacrack.o 作为对象依赖项
  • 修改了 Makefile.in 以包含 cudacrack.h 作为源文件
  • 清理干净
  • 编译 cudacrack.c 使用:g++ -c cudacrack.c -o cudacrack.o
  • ./配置
  • make --debug==verbose

我在链接过程中收到此错误:

g++ -L/usr/local/cuda/lib64/ -lcuda -lcudart  -g -O2 -funroll-loops -O3   -o fcrackzip  main.o crack.o cudacrack.o
main.o: In function `main':
$HOME/fcrackzip/fcrackzip-1.0/main.c:367: undefined reference to `runCudaImplementation'
collect2: ld returned 1 exit status

注意:此时“cuda”文件名只包含基本的C方法。稍后我将使用 nvcc 编译这部分。我在这里解释了我的另一个问题:Building GPL C program with CUDA module

Some debug info from make:
     Considering target file `cudacrack.h'.
       Finished prerequisites of target file `cudacrack.h'.
      No commands for `cudacrack.h' and no prerequisites actually changed.
      No need to remake target `cudacrack.h'.

..later..

    Considering target file `cudacrack.o'.
      Considering target file `cudacrack.c'.
       Finished prerequisites of target file `cudacrack.c'.
      No need to remake target `cudacrack.c'.
     Finished prerequisites of target file `cudacrack.o'.
     Prerequisite `cudacrack.c' is older than target `cudacrack.o'.
    No need to remake target `cudacrack.o'.

make 需要做什么才能将主程序与 cudacrack.o 依赖项链接起来?

【问题讨论】:

  • 如果您向我们展示了您的 makefile 如何构建其他对象,这将有所帮助——我怀疑问题在于那里的不兼容。尝试一个更简单的案例;为cudacrack 编写一个小测试例程(如果您还没有)并确认您可以构建和运行它。然后尝试中间情况...

标签: makefile cuda autotools


【解决方案1】:

您是否检查过符号runCudaImplementation 是否实际定义在cudacrack.o 中?可能是因为你使用 g++ 而不是 gcc 来编译它。

【讨论】:

  • 我认为你赢了:$ objdump的-t cudacrack.o:00000000亿克˚F的.text 000000000000000b _Z21runCudaImplementationv,$ objdump的-t -C cudacrack.o:00000000亿克˚F的.text 000000000000000b runCudaImplementation()编辑:它在使用 gcc 时有效。谢谢!
猜你喜欢
  • 2017-06-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多