C++ libPNG

I am getting the following error when trying to compile....

Undefined symbols for architecture x86_64: "_png_sig_cmp", referenced from: RenderUtils::isValidPng(std::istream&) in RenderUtils.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

my code is as follows:

//called from here
ifstream s;
s.open("/Users/tmg06qyu/Desktop/texture_512.png", ios::binary);

if(!RenderUtils::isValidPng(s)){
    throw 20;
}


//header
class RenderUtils{
public:
    static bool isValidPng(std::istream &source);
};



//implementation
#include <iostream>
#include "RenderUtils.h"
#include "png.h"
#define PNGSIGSIZE 8


using namespace std;

bool RenderUtils::isValidPng(std::istream &source){
//Allocate a buffer of 8 bytes, where we can put the file signature.
png_byte pngsig[PNGSIGSIZE];
int is_png = 0;

//Read the 8 bytes from the stream into the sig buffer.
source.read((char*)pngsig, PNGSIGSIZE);

//Check if the read worked...
if (!source.good()) return false;

//Let LibPNG check the sig. If this function returns 0, everything is OK.
is_png = png_sig_cmp(pngsig, 0, PNGSIGSIZE);
return (is_png == 0);
}

My guess is that you built a 32-bit version of libpng, but now you are trying to link 64-bit code with it. Try file * or otool -L * to check (from memory)


Sorry everyone....stupid me. I needed to link against zlib.....note to self.....always read the readme....(well not always!)

链接地址: http://www.djcxy.com/p/86336.html

上一篇: 编译.C文件:架构x86的未定义符号

下一篇: C ++ libPNG