1

コンパイルしようとすると、次のエラーが発生します....

アーキテクチャ 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);
}
4

2 に答える 2

0

私の推測では、32ビットバージョンのlibpngを作成しましたが、現在は64ビットコードをそれにリンクしようとしています。試してみるfile *otool -L *、(メモリから)チェックしてください

于 2012-07-26T13:40:12.257 に答える
0

みんなごめんね……バカ。私はzlibにリンクする必要がありました.....自分自身に注意してください.....常にreadmeを読んでください....(常にではありません!)

于 2012-07-26T15:32:56.883 に答える