1
libpng 라이브러리에 연결하는 데 문제가 있습니다. 빌드가 Libpng 호출에 대한 참조를 정의 할 수 없습니다. 문제는 내 Libpng 설치에 있다고 생각합니다. 나는 내 빌드 환경이 같다 Win7에 노트북에와 Mingw 환경에서들이받은하고LibPng 라이브러리에 연결하는 중에 오류가 발생했습니다.
은 다음과 같습니다
My path starts with C:\MinGW\bin;C:\MinGW\msys\1.0\bin;C:\MinGW\git\cmd;C:\Program Files
C:\Users\Bob\Home\png23d>g++ --version
g++ (GCC) 5.3.0
I have built and installed libpng-1.6.28 which creates the following:
C:\MinGW\bin>
libpng-config
libpng16-config
libpng16.dll
C:\MinGW\include\libpng
png.h
pngconf.h
pnglibconf.h
C:\MinGW\include\libpng16
png.h
pngconf.h
pnglibconf.h
C:\MinGW\lib\pkgconfig
C:\MinGW\lib>
libpng.a
libpng.dll.a
libpng16.a
libpng16.dll.a
a symbolic link `libpng' to `libpng16'
a symbolic link `libpng.pc' to `libpng16.pc'
a symbolic link `libpng.a' to `libpng16.a'
a symbolic link `libpng-config' to `libpng16-config
내가 프로그램을 빌드 할 때 "png23d"나는 다음과 같은 얻을
C:\Users\Bob\Home\png23d>make
g++ -DUSE_LIBPNG -lpng png23d.o option.o bitmap.o mesh.o mesh_gen.o mesh_index.o mesh_simplify.o out_pgm.o out_rscad.o out_pscad.o out_stl.o -o png23d
bitmap.o:bitmap.c:(.text+0x102): undefined reference to `png_sig_cmp'
bitmap.o:bitmap.c:(.text+0x142): undefined reference to `png_create_read_struct'
.
.
.
bitmap.o:bitmap.c:(.text+0x418): undefined reference to `png_read_end'
bitmap.o:bitmap.c:(.text+0x466): undefined reference to `png_destroy_read_struct'
collect2.exe: error: ld returned 1 exit status
<builtin>: recipe for target 'png23d' failed
make: *** [png23d] Error 1
나는 거의 작동하지 않는 -lpng이라고 확신한다. 나는 그것을 고치는 법을 모른다. 심볼릭 링크 문제라고 생각하고 있으며 libpng 빌드 중 하나를 만들지 않았다는 것을 알고 있습니다. 내가 옳다면 무엇을 연결해야합니까.
-lpng를 -llpng16으로 변경해 보았습니다. 아무런 차이가 없었습니다.
명령 프롬프트에서 올바르게 작동합니다. 그냥 make 파일을 변경하는 방법을 알아 내야합니다.
#!/usr/bin/make
#
# png23d is a program to convert png images into 3d files
#
# Copyright 2011 Vincent Sanders <[email protected]>
#
# Released under the MIT License,
# http://www.opensource.org/licenses/mit-license.php
CC = g++
VERSION=100
PREFIX =
WARNFLAGS = -W -Wall -Wundef -Wpointer-arith \
-Wcast-align -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \
-Wnested-externs
ifneq ($(GCCVER),2)
WARNFLAGS += -Wno-unused-parameter
endif
OPTFLAGS=-O2
#OPTFLAGS=-O0
CFLAGS+=$(WARNFLAGS) -MMD -DVERSION=$(VERSION) $(OPTFLAGS) -g
LDFLAGS+= -DUSE_LIBPNG -lpng
PNG23D_OBJ=png23d.o option.o bitmap.o mesh.o mesh_gen.o mesh_index.o mesh_simplify.o out_pgm.o out_rscad.o out_pscad.o out_stl.o
.PHONY : all clean
all:png23d
png23d:$(PNG23D_OBJ)
-include $(PNG23D_OBJ:.o=.d)
-include test/Makefile.sub
clean: testclean
${RM} png23d $(PNG23D_OBJ) *.d *~ png23d.png
install:png23d
install -D png23d $(DESTDIR)$(PREFIX)/bin
install-man:png23d.1
install -D png23d.1 $(DESTDIR)$(PREFIX)/share/man/man1
# logo creation
png23d.png:png23d.pov
povray +L/usr/share/povray/include/ -D +Q11 [email protected] +UV +UL +A0.2 +FP8 +W400 +H300 $<
명령 프롬프트에서 올바르게 작동합니다. makefile을 변경하는 방법을 알아 내야합니다. 메인 질문에 메이크 파일이 추가되었습니다. –
@RobertWorkman 대신에'-lpng'를'LDLIBS'에 넣으십시오. ([make docs] (https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter 참조) /make_10.html) 암시 적 메이크 파일 규칙에 대한 자세한 정보를 참조하십시오. – yugr