0

我正在尝试编译可在线获得的代码Non-Local Means Denoising

当我编译源代码时,出现以下错误,我认为主要是由于libpng

  g++  -L/opt/local/lib/ -L/usr/local/lib/ -L/usr/lib/x86_64-linux-gnu/ -fopenmp -lpng    
  -o nlmeans_ipol  nlmeans_ipol.o io_png.o libauxiliar.o libdenoising.o mt19937ar.o
  io_png.o: In function `io_png_write_raw':
  io_png.c:(.text+0xe0): undefined reference to `png_create_write_struct'
  io_png.c:(.text+0xf6): undefined reference to `png_create_info_struct'
  io_png.c:(.text+0x12b): undefined reference to `png_init_io'
  io_png.c:(.text+0x194): undefined reference to `png_set_IHDR'
  io_png.c:(.text+0x1a6): undefined reference to `png_write_info'
  io_png.c:(.text+0xb36): undefined reference to `png_write_image'
  io_png.c:(.text+0xb48): undefined reference to `png_write_end'
  io_png.c:(.text+0xb62): undefined reference to `png_destroy_write_struct'
  io_png.c:(.text+0xbcc): undefined reference to `png_destroy_write_struct'
  io_png.c:(.text+0xc1f): undefined reference to `png_destroy_read_struct'
  io_png.c:(.text+0xe6a): undefined reference to `png_destroy_write_struct'
  io_png.c:(.text+0xe80): undefined reference to `png_destroy_write_struct'

我遵循以下线程并将文件“libpng.a”放置在许多位置,但它没有帮助。

我在这里看到了类似的 libpng 问题,但没有帮助。

我正在使用 ubuntu 12.04。

谁能告诉我实际上可能出了什么问题?

编辑 1 完整的调用如下

  g++ -O3 -funroll-loops -fomit-frame-pointer  -fno-tree-pre -falign-loops -ffast-math -ftree-vectorize -Wall -Wextra -Wno-write-strings -Wno-deprecated -ansi -fopenmp   -c -o nlmeans_ipol.o nlmeans_ipol.cpp
  cc -c -o io_png.o  io_png.c -O3 -funroll-loops -fomit-frame-pointer  -fno-tree-pre -falign-loops -ffast-math -ftree-vectorize -Wall -Wextra -Wno-write-strings -ansi -I/opt/local/include/ -I/usr/local/include/   
  g++ -c -o libauxiliar.o  libauxiliar.cpp -O3 -funroll-loops -fomit-frame-pointer  -fno-tree-pre -falign-loops -ffast-math -ftree-vectorize -Wall -Wextra -Wno-write-strings -Wno-deprecated -ansi -fopenmp -I/opt/local/include/ -I/usr/local/include/ 
  g++ -c -o libdenoising.o  libdenoising.cpp -O3 -funroll-loops -fomit-frame-pointer  -fno-tree-pre -falign-loops -ffast-math -ftree-vectorize -Wall -Wextra -Wno-write-strings -Wno-deprecated -ansi -fopenmp -I/opt/local/include/ -I/usr/local/include/ 
  cc -c -o mt19937ar.o  mt19937ar.c -O3 -funroll-loops -fomit-frame-pointer  -fno-tree-pre -falign-loops -ffast-math -ftree-vectorize -Wall -Wextra -Wno-write-strings -ansi -I/opt/local/include/ -I/usr/local/include/   
  g++ -lpng -lm -fopenmp -L/opt/local/lib/ -L/usr/local/lib/ -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/ -fopenmp -lpng -lpngwriter -lz -lfreetype -o nlmeans_ipol  nlmeans_ipol.o io_png.o libauxiliar.o libdenoising.o mt19937ar.o

这是完整的电话。它是一个make文件,上面的转储在命令提示符处显示的副本中。

4

1 回答 1

2

尝试仅更改g++调用中的参数顺序并-lpng在目标文件后面。链接器按照给定的顺序评估参数,因此当它获取时它-lpng还不知道,io_png.o因此它不会从库中链接必要的代码

编辑:

makefile 执行的最后一个命令是:

g++ -lpng -lm -fopenmp -L/opt/local/lib/ -L/usr/local/lib/ -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/ -fopenmp -lpng -lpngwriter -lz -lfreetype -o nlmeans_ipol  nlmeans_ipol.o io_png.o libauxiliar.o libdenoising.o mt19937ar.o

如果应该是这样的

g++ -L/opt/local/lib/ -L/usr/local/lib/ -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/   -o nlmeans_ipol  nlmeans_ipol.o io_png.o libauxiliar.o libdenoising.o mt19937ar.o -lpng -lm -fopenmp -lpngwriter -lz -lfreetype

我不知道每个库,可能-l...参数的顺序仍然不对

于 2013-11-05T12:41:12.183 回答