glpng

chaleur
Unregistered
 
Post: #1
I've been trying to get the glpng library compiled under OSX and am having some trouble. This is probably because I am massively ignorant as to how libraries work on my (relatively new) Mac. Has anyone else done this that can advise me?

I downloaded glpng from here:

http://www.wyatt100.freeserve.co.uk/download.htm

It comes with a Linux and an SGI makefile, as well as a Qt tmake/qmake .pro file. I used the .pro file and Qt's qmake to generate a Makefile for the project, which I've posted here:

http://www.cpsc.ucalgary.ca/~katherim/Makefile

Compile goes fine, but I get the following ranlib error:

ranlib -s libglpng.a
ranlib: file: libglpng.a(pngpread.o) has no symbols

I don't understand what ranlib is well enough to know what this means, and how I can go about fixing it. The man page says it creates a library for use with the link editor, _ld_. I've no idea what a link editor is, or why I'd want to use one. The man page for _ld_ calls it the "Mach object file link editor". Okay, call me confused ;-).

First of all, shouldn't I be creating a .dylib, and not a .a file, or does it matter? Is one just dynamic and the other static on OSX? If so, I can link my code to either, and it doesn't matter. I'm moving to OSX from linux, where I confess I've only ever made static libraries, so please forgive my ignorance in these issues.

Any help is appreciated, including help of the "Go read this and see if you learn something" variety. I don't mind reading docs at all, I'm just not sure where to start. Of course if someone has managed to link/use the glpng library successfully I wouldn't be adverse to that kind of help Smile.

For the record, I have tried just using libpng (which I did get compiled under OS X), but I'm having trouble getting it to read alpha values properly on any platform, so I'm going back to trying to get glpng to work, since it's smaller, and I can make it work under (eeek) .NET. However, I really don't want to be condemned to working exclusively in Windows, so all help is greatly appreciated ;-).

Kaye Mason
Quote this message in a reply
Member
Posts: 131
Joined: 2004.10
Post: #2
makefile.txt
Code:
##################################################
# Common to all makefiles.
##################################################

# Building Release.
#
#INCLUDE=-include ../osx.h
#LIB_INCLUDE=-include ../../osx.h
#
#BUILD_DIR=release
#EXTRA_CCFLAGS=-Os -Wuninitialized -F./release

# Building Debug.
#
PREFIX=-include ../osxd.h
LIB_PREFIX=-include ../../osxd.h
#
BUILD_DIR=debug
EXTRA_CCFLAGS = -g -O0 -ffix-and-continue -F./debug


# Compiler
CC = /usr/bin/gcc-3.3

CCFLAGS = -x c -arch ppc -pipe -Wno-trigraphs -fasm-blocks -fpascal-strings \
    -mtune=G4 -Wunused-function -Wunused-variable  -Wunused-value \
    -pedantic -fmessage-length=0 $(EXTRA_CCFLAGS)


# Libtools
LIBTOOL = /usr/bin/libtool

RANLIB = /usr/bin/ranlib


# Linker
LINKER = /usr/bin/gcc-3.3

#-prebind
LINKER_FLAGS=-arch ppc -Wl,-no_arch_warnings

glpng makefile
Code:
##################################################
# glpng makefile
##################################################

##################################################
# common values for building.
#
include ../makefile.txt

##################################################
# what are we building
#
all: glpng

SRCS = glpng.c


##################################################
# Build specifics
#
LOCAL_CCFLAGS = -I../zlib  \
    -I../lpng128

LOCAL_LIBTOOLFLAGS = -static -framework OpenGL

.c.o:
    @echo ===========================================
    $(CC) $(CCFLAGS) $(LIB_PREFIX) $(LOCAL_CCFLAGS) -c $*.c -o $*.o

OBJS = $(SRCS:.c=.o)


##################################################
# The guts of the building.
#
glpng: $(OBJS)
    @echo ===========================================
    @echo === Making the lib
    @echo ===========================================
    $(LIBTOOL) $(LOCAL_LIBTOOLFLAGS) -o libglpng.a $(OBJS)

    $(RANLIB) libglpng.a

clean:
    rm -rf $(BUILD_DIR)

Note in glpng makefile, make sure the zlib and lpng references are pointing correctly. makefile.txt is just breaking out some settings that are common to multiple makefiles. I've used it in a number of places in a project I'm working on.

All you have to do then is just type "make" at the command prompt in your glpng directory and it should build ok.



However if you want an xcode project then the following will do.

Xcode project contents. glpng.xcode/project.pbxproj
Code:
// !$*UTF8*$!
{
    archiveVersion = 1;
    classes = {
    };
    objectVersion = 39;
    objects = {
        014CEA520018CE5811CA2923 = {
            buildSettings = {
                COPY_PHASE_STRIP = NO;
                GCC_DYNAMIC_NO_PIC = NO;
                GCC_ENABLE_FIX_AND_CONTINUE = YES;
                GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
                GCC_OPTIMIZATION_LEVEL = 0;
                GCC_PREFIX_HEADER = ../../osx.h;
                GCC_WARN_PEDANTIC = YES;
                GCC_WARN_UNUSED_FUNCTION = YES;
                GCC_WARN_UNUSED_VALUE = YES;
                GCC_WARN_UNUSED_VARIABLE = YES;
                HEADER_SEARCH_PATHS = "../lpng128 ../zlib";
                OBJROOT = debug/;
                SYMROOT = debug/;
                ZERO_LINK = YES;
            };
            isa = PBXBuildStyle;
            name = Development;
        };
        014CEA530018CE5811CA2923 = {
            buildSettings = {
                COPY_PHASE_STRIP = YES;
                GCC_ENABLE_FIX_AND_CONTINUE = NO;
                GCC_PREFIX_HEADER = ../../osx.h;
                GCC_WARN_PEDANTIC = YES;
                GCC_WARN_UNINITIALIZED_AUTOS = YES;
                GCC_WARN_UNUSED_FUNCTION = YES;
                GCC_WARN_UNUSED_VALUE = YES;
                GCC_WARN_UNUSED_VARIABLE = YES;
                HEADER_SEARCH_PATHS = "../zlib ../lpng128";
                OBJROOT = release/;
                SYMROOT = release/;
                ZERO_LINK = NO;
            };
            isa = PBXBuildStyle;
            name = Deployment;
        };
//010
//011
//012
//013
//014
//080
//081
//082
//083
//084
        08FB7793FE84155DC02AAC07 = {
            buildSettings = {
            };
            buildStyles = (
                014CEA520018CE5811CA2923,
                014CEA530018CE5811CA2923,
            );
            hasScannedForEncodings = 1;
            isa = PBXProject;
            mainGroup = 08FB7794FE84155DC02AAC07;
            projectDirPath = "";
            targets = (
                D2AAC045055464E500DB518D,
            );
        };
        08FB7794FE84155DC02AAC07 = {
            children = (
                AB5A027907A89DB5000CFE8A,
                08FB7795FE84155DC02AAC07,
                C6A0FF2B0290797F04C91782,
                1AB674ADFE9D54B511CA2CBB,
            );
            isa = PBXGroup;
            name = glpng;
            refType = 4;
            sourceTree = "<group>";
        };
        08FB7795FE84155DC02AAC07 = {
            children = (
                AB5A021F07A8997B000CFE8A,
                AB5A022007A8997B000CFE8A,
            );
            isa = PBXGroup;
            name = Source;
            refType = 4;
            sourceTree = "<group>";
        };
//080
//081
//082
//083
//084
//1A0
//1A1
//1A2
//1A3
//1A4
        1AB674ADFE9D54B511CA2CBB = {
            children = (
                D2AAC046055464E500DB518D,
            );
            isa = PBXGroup;
            name = Products;
            refType = 4;
            sourceTree = "<group>";
        };
//1A0
//1A1
//1A2
//1A3
//1A4
//AB0
//AB1
//AB2
//AB3
//AB4
        AB5A021F07A8997B000CFE8A = {
            fileEncoding = 30;
            isa = PBXFileReference;
            lastKnownFileType = sourcecode.c.c;
            path = glpng.c;
            refType = 4;
            sourceTree = "<group>";
        };
        AB5A022007A8997B000CFE8A = {
            fileEncoding = 30;
            isa = PBXFileReference;
            lastKnownFileType = sourcecode.c.h;
            path = glpng.h;
            refType = 4;
            sourceTree = "<group>";
        };
        AB5A022107A8997B000CFE8A = {
            fileRef = AB5A021F07A8997B000CFE8A;
            isa = PBXBuildFile;
            settings = {
            };
        };
        AB5A022207A8997B000CFE8A = {
            fileRef = AB5A022007A8997B000CFE8A;
            isa = PBXBuildFile;
            settings = {
            };
        };
        AB5A027907A89DB5000CFE8A = {
            isa = PBXFileReference;
            lastKnownFileType = wrapper.framework;
            name = OpenGL.framework;
            path = /System/Library/Frameworks/OpenGL.framework;
            refType = 0;
            sourceTree = "<absolute>";
        };
        AB5A027A07A89DB5000CFE8A = {
            fileRef = AB5A027907A89DB5000CFE8A;
            isa = PBXBuildFile;
            settings = {
            };
        };
//AB0
//AB1
//AB2
//AB3
//AB4
//C60
//C61
//C62
//C63
//C64
        C6A0FF2B0290797F04C91782 = {
            children = (
            );
            isa = PBXGroup;
            name = Documentation;
            refType = 4;
            sourceTree = "<group>";
        };
//C60
//C61
//C62
//C63
//C64
//D20
//D21
//D22
//D23
//D24
        D289987405E68DCB004EDB86 = {
            buildActionMask = 2147483647;
            files = (
                AB5A027A07A89DB5000CFE8A,
            );
            isa = PBXFrameworksBuildPhase;
            runOnlyForDeploymentPostprocessing = 0;
        };
        D2AAC043055464E500DB518D = {
            buildActionMask = 2147483647;
            files = (
                AB5A022207A8997B000CFE8A,
            );
            isa = PBXHeadersBuildPhase;
            runOnlyForDeploymentPostprocessing = 0;
        };
        D2AAC044055464E500DB518D = {
            buildActionMask = 2147483647;
            files = (
                AB5A022107A8997B000CFE8A,
            );
            isa = PBXSourcesBuildPhase;
            runOnlyForDeploymentPostprocessing = 0;
        };
        D2AAC045055464E500DB518D = {
            buildPhases = (
                D2AAC043055464E500DB518D,
                D2AAC044055464E500DB518D,
                D289987405E68DCB004EDB86,
            );
            buildRules = (
            );
            buildSettings = {
                GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
                INSTALL_PATH = /usr/local/lib;
                LIBRARY_STYLE = STATIC;
                PRODUCT_NAME = glpng;
            };
            dependencies = (
            );
            isa = PBXNativeTarget;
            name = glpng;
            productName = glpng;
            productReference = D2AAC046055464E500DB518D;
            productType = "com.apple.product-type.library.static";
        };
        D2AAC046055464E500DB518D = {
            explicitFileType = archive.ar;
            includeInIndex = 0;
            isa = PBXFileReference;
            path = libglpng.a;
            refType = 3;
            sourceTree = BUILT_PRODUCTS_DIR;
        };
    };
    rootObject = 08FB7793FE84155DC02AAC07;
}
[
Quote this message in a reply
Post Reply