Pregunta

I am trying to compile the code which is available online Non-Local Means Denoising

When I compile the source, the following errors appear that I suppose are mainly due to 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'

I have followed the following threads and placed the file "libpng.a" at many locations but it does not help.

I have seen a similar libpng problem here but does not help.

I am using ubuntu 12.04.

Could anyone please tell what could actually go wrong?

EDIT 1 The complete call is as follows

  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

this is the complete call. Its a make file, The dump above in the copy of what appears at the command prompt.

¿Fue útil?

Solución

Try just changing the sequence of parameters in your g++ call and have -lpng behind the object files. The linker evalueates the arguments in the sequence they are given so when it gets -lpng it has not yet knowledge of io_png.o and so it doesn't link the neccessary code from the library

Edit:

The last command of what your makefile executes is:

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

If should be something like

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

I don't know each of the libraries, maybe the sequence of the -l... parameters still isn't right

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top