Old 11-03-2017, 12:21 PM   #1
Veto
Human being with feelings
 
Join Date: Aug 2010
Posts: 691
Default Troubles with libpng and LICE_WritePNG on linux

Hi all,
I'm a WDL & C/C++ newbie and I'm having problems using libpng provided with Justins WDL (I'd like to play with the latest SWELL additions for linux and the big goal is trying to port the Licacap CLI version if/when I'm familiar with it).

I would like to use LICE_WritePNG(). After solving all dependencies for that function (I think I need pngwrite.c, pngerror.c and pngmem.c) the linker complains about undefined references. When I add the linker flag -lpng to my gcc command, which links to the system installation of the libpng library, everything works just fine.
My Question is why is that flag necessary? Isn't WDL designed the way that the system installation of libpng isn't needed or did I misunderstood?

Also I checked the makefile to build the SWS extension (reaper_sws64.so), which uses the same WDL source but don't seem to depend on this flag.

Here is the error message with the flag unset:
Code:
cc -Wall   -c -o main.o main.c
g++    -c -o lice_png_write.o ../../WDL/WDL/lice/lice_png_write.cpp
cc -Wall   -c -o pngwrite.o ../../WDL/WDL/libpng/pngwrite.c
cc -Wall   -c -o pngerror.o ../../WDL/WDL/libpng/pngerror.c
cc -Wall   -c -o pngmem.o ../../WDL/WDL/libpng/pngmem.c
g++ -o test -Wall main.o lice_png_write.o pngwrite.o pngerror.o pngmem.o 
lice_png_write.o: In function `LICE_WritePNG(char const*, LICE_IBitmap*, bool)':
lice_png_write.cpp:(.text+0x8f): undefined reference to `png_create_write_struct'
lice_png_write.cpp:(.text+0xbe): undefined reference to `png_create_info_struct'
lice_png_write.cpp:(.text+0xe8): undefined reference to `png_destroy_write_struct'
lice_png_write.cpp:(.text+0x15b): undefined reference to `png_destroy_write_struct'
lice_png_write.cpp:(.text+0x178): undefined reference to `png_init_io'
lice_png_write.cpp:(.text+0x1f1): undefined reference to `png_set_IHDR'
lice_png_write.cpp:(.text+0x204): undefined reference to `png_write_info'
lice_png_write.cpp:(.text+0x210): undefined reference to `png_set_bgr'
lice_png_write.cpp:(.text+0x231): undefined reference to `png_set_filler'
lice_png_write.cpp:(.text+0x2c8): undefined reference to `png_write_row'
lice_png_write.cpp:(.text+0x2f4): undefined reference to `png_write_end'
lice_png_write.cpp:(.text+0x307): undefined reference to `png_destroy_write_struct'
collect2: error: ld returned 1 exit status
And this is main.c:
Code:
#include <stdio.h>

int main ()
{
	printf("---yeah!---\n");
	return 1;
}

Last edited by Veto; 11-03-2017 at 06:06 PM.
Veto is offline   Reply With Quote
Old 11-03-2017, 03:53 PM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 6,789
Default

Maybe you just need more of the libpng source files built into your project? And libpng itself may depend on more things...
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 11-03-2017, 05:59 PM   #3
Veto
Human being with feelings
 
Join Date: Aug 2010
Posts: 691
Default

Thank you Xen, I could solve some of the "undefined references" by adding more source files (I searched for function definitions in WDL subfolders).

Still I couldn't solve those remaining 7:
Code:
lice_png_write.cpp:(.text+0x8f): undefined reference to `png_create_write_struct'
lice_png_write.cpp:(.text+0xe8): undefined reference to `png_destroy_write_struct'
lice_png_write.cpp:(.text+0x15b): undefined reference to `png_destroy_write_struct'
lice_png_write.cpp:(.text+0x204): undefined reference to `png_write_info'
lice_png_write.cpp:(.text+0x2c8): undefined reference to `png_write_row'
lice_png_write.cpp:(.text+0x2f4): undefined reference to `png_write_end'
lice_png_write.cpp:(.text+0x307): undefined reference to `png_destroy_write_struct'
All of them are about writing PNG's apparently.
png_write_info(), png_write_row() and png_write_end() at least are defined in pngwrite.c which I already added. Still I get the errors.
Are they disabled by a macro which I need to define?

So I guess the real question of this thread is: Which sources I need for LICE_WritePNG() and how do I use it/ what do I need to define?
This in licecap_cli.cpp doesn't work.

My full log:
Code:
cc -Wall    -c -o main.o main.c
g++    -c -o lice_png_write.o ../../WDL/WDL/lice/lice_png_write.cpp
cc -Wall    -c -o pngwrite.o ../../WDL/WDL/libpng/pngwrite.c
cc -Wall    -c -o pngerror.o ../../WDL/WDL/libpng/pngerror.c
cc -Wall    -c -o pngmem.o ../../WDL/WDL/libpng/pngmem.c
cc -Wall    -c -o png.o ../../WDL/WDL/libpng/png.c
cc -Wall    -c -o adler32.o ../../WDL/WDL/zlib/adler32.c
cc -Wall    -c -o crc32.o ../../WDL/WDL/zlib/crc32.c
cc -Wall    -c -o infback.o ../../WDL/WDL/zlib/infback.c
cc -Wall    -c -o inffast.o ../../WDL/WDL/zlib/inffast.c
cc -Wall    -c -o inflate.o ../../WDL/WDL/zlib/inflate.c
cc -Wall    -c -o inftrees.o ../../WDL/WDL/zlib/inftrees.c
cc -Wall    -c -o uncompr.o ../../WDL/WDL/zlib/uncompr.c
cc -Wall    -c -o zutil.o ../../WDL/WDL/zlib/zutil.c
cc -Wall    -c -o pngset.o ../../WDL/WDL/libpng/pngset.c
cc -Wall    -c -o pngtrans.o ../../WDL/WDL/libpng/pngtrans.c
g++ -o test -Wall  main.o lice_png_write.o pngwrite.o pngerror.o pngmem.o png.o adler32.o crc32.o infback.o inffast.o inflate.o inftrees.o uncompr.o zutil.o pngset.o pngtrans.o 
lice_png_write.o: In function `LICE_WritePNG(char const*, LICE_IBitmap*, bool)':
lice_png_write.cpp:(.text+0x8f): undefined reference to `png_create_write_struct'
lice_png_write.cpp:(.text+0xe8): undefined reference to `png_destroy_write_struct'
lice_png_write.cpp:(.text+0x15b): undefined reference to `png_destroy_write_struct'
lice_png_write.cpp:(.text+0x204): undefined reference to `png_write_info'
lice_png_write.cpp:(.text+0x2c8): undefined reference to `png_write_row'
lice_png_write.cpp:(.text+0x2f4): undefined reference to `png_write_end'
lice_png_write.cpp:(.text+0x307): undefined reference to `png_destroy_write_struct'
collect2: error: ld returned 1 exit status
Veto is offline   Reply With Quote
Old 11-03-2017, 06:44 PM   #4
Veto
Human being with feelings
 
Join Date: Aug 2010
Posts: 691
Default

Quote:
Originally Posted by Veto View Post
Are they disabled by a macro which I need to define?
This indeed seems to be the case.

I had a look at the Licecap Visual Studio project file in a text editor and I think this
Code:
/D "PNG_WRITE_SUPPORTED"
means I have to define "PNG_WRITE_SUPPORTED".

Really should have looked in the .dsp file earlier as all sources for compiling Licecap are in there listed too.

Except a (few) functions that need to be implemented in SWELL, I now can licecap_cli.cpp get built.
Thanks again Xen.
Veto is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.