How to build libpng using gcc? - gcc

I am currently working on a program that will have to be able to read and save PNG files. I've decided to use libpng so I've downloaded it's source files. I unpacked them and here is where my problem started.
There are very many files in the unpacked folder and I don't know which of them I should compile to get proper.o files that I will be able to link to my program.

There are makefiles in the libpng "scripts" directory. Most of those contain a list of the files that need to be compiled (namely, all of png*.c in the main libpng directory except for pngtest.c).
You'll also need pnglibconf.h which you can create by copying scripts/pnglibconf.h_prebuilt.

Related

Linking my CMAKE project with libpng in Windows

I'm working on a C++ project that requires libpng. So far I've worked on Linux and everything is smooth. I installed libpng, CMAKE picks it up and everything is alright. Now move to Windows.
Here I first installed zlib (required by libpng) and libpng. When I say install, I mean I downloaded the source files, and then built them and install them using msbuild.
I noticed that by doing so, I got new folders under c:\program files (x86):
c:\program files (x86)\zlib
c:\program files (x86)\libpng
Seemed all right to me. Now when I configure my project with CMAKE zlib is picked up:
-- Found ZLIB: C:/Program Files (x86)/zlib/lib/zlib.lib (found version "1.2.13")
but there's no way CMAKE finds the PNG library:
Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
Now I tried to have a look at the FindPNG and I noticed this line:
find_path(PNG_PNG_INCLUDE_DIR png.h PATH_SUFFIXES include/libpng)
Does this mean that CMAKE expects the file png.h to be in a directory ending in include/libpng? If so, then it will never find it because in my case png.h is placed in libpng/include. But this is also the "official" installation from the source code just downloaded from http://www.libpng.org/pub/png/libpng.html.
So now I am superconfused. How things are supposed to work in Windows? Should I "create" a folder structure with the correct files for every library so that CMAKE is happy? In a way I hoped things in Windows were similar to what happens in Linux: libraries go in a standard folder, they are detected by CMAKE.. everything is ok. But apparently this is not the case. So my question in general is: how do you ship a package like this to a Windows user so that he can builds it without having to go through all this?
Thanks so much
Fabrizio
This would be the right one to use:
find_package(PNG)
You can tell CMake to look in the location where you installed it by adding the libpng base install location to CMAKE_PREFIX_PATH. Without this, CMake doesn't know where you put it.
cmake "-DCMAKE_PREFIX_PATH=C:/Program Files (x86)/libpng" ...
Note that FindPNG first looks for zlib and will fail if zlib could not be found.

Why Do the Lua Binaries Contain .h and .c Files, but Lua IUP Binaries Contain .DLLs?

I'm trying to update an old app that uses Lua and IUP, but I'm not very experienced, so I'm wondering if I have too many files. I originally downloaded Lua 5.4.3 and followed a tutorial on how to turn those .c and .h files into Lua.dll, Lua.exe, Lua.lib, and Luac.exe.
Then I downloaded iup-3.30-Lua54_Win64_bin.zip and extracted to it's own folder. That folder contains a bunch of .DLLs and a few .EXEs. Since those files have their own interpreter (iuplua54.exe), are the files in Lua 5.4.3 unnecessary? Why do these downloads have different file types? Did I install them wrong or did I get the wrong files?
I'm having issues with different Lua .exe files giving me different errors when I try to open a particular .lua script.

Using SDL-C library with Code::Blocks on Windows...wizard can't locate SDLmain library file

I am new to programming and I am trying to use SDL library with Code::Blocks on Windows. I downloaded the Library from : https://www.libsdl.org/download-2.0.php.
I downloaded the files, decompressed and then copied SDL.dll file in
C:\Program Files (x86)\CodeBlocks\MinGW\bin
and then the include and lib files in
C:\Program Files (x86)\CodeBlocks\SDL,
which is a new file I created. However, when I open Code::Blocks, new SDL project and arrive at the step where I am supposed to give the directory where the include and lib files are, once I hit next I get the following error :
The path you entered seems valid but the wizard can't locate the following SDL's library file: SDLmain in it.
Any idea why this might be happening and how I can fix it?

Does Boost BCP also copy the required LIB files?

This may be a no-brainer for longtime boost users, but I’m just getting into boost.
I built the full boost distribution and BCP to extract just the parts I need to put in my VisualStudio C++ project.
What I found is when I call bcp, it copies the source tree to the destination. It doesn’t copy the required compiled lib files though (for those modules that need it).
So when I build my project and include
#include "boost/program_options.hpp"
for example, I get a linker error:
*Error 1 error LNK1104: cannot open file 'libboost_program_options-vc100-mt-sgd-1_54.lib'*
So my question is this:
should BCP also copy over the compiled LIB files as necessary ?
or
is it standard procedure for users of BOOST to manually copy those complied library files themselves?
I recently started experimenting with BCP. It seems like any boost modules that require libraries will not be copied, but instead they need to be built using bjam.
For example, when you run bcp on your code it will output some 'INFO' statements like this:
INFO: tracking source dependencies of library date_time due to presence of BOOST_DATE_TIME_DECL...
INFO: tracking source dependencies of library smart_ptr due to presence of "void sp_scalar_constructor_hook...
Notice that in addition to the generated 'boost' folder containing a bunch of copied boost header files there will be a 'libs' folder along with Jam files (Jamroot, Jamfile.v2, etc).
I think you need to cd to the directories with the Jamfiles and use bjam to build the needed libraries.
Maybe this answer will help:
Building a subset of boost in windows

How to create a .tar.gz source archive in netbeans c++

I wish to be able to redistribute the source for my netbeans project, preferably in a .tar.gz source archive. Currently if I just copy the source files, the makefile, and the relevant mk files from nbproject, it doesn't work. When I try and compile on another machine, make will complain that it can't find the source code, as the makefile tries to compile /home/user/netbeansprojecs/project/sourcefile, instead of the source files in the same folder as it.

Resources