コンパイルしようとすると、次のエラーが発生します....
アーキテクチャ x86_64 の未定義シンボル: "_png_sig_cmp"、参照先: RenderUtils.old 内の RenderUtils::isValidPng(std::istream&): アーキテクチャ x86_64 のシンボルが見つかりませんでした。clang: エラー: リンカ コマンドが終了コード 1 で失敗しました ( -v を使用して呼び出しを確認します)
私のコードは次のとおりです。
//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);
}