簡體   English   中英

C ++ libPNG-簡單的初始化錯誤

[英]C++ libPNG - simple initialisation error

嘗試編譯時出現以下錯誤。

架構x86_64的未定義符號:“ _ png_sig_cmp”,引用自:RenderUtils.o中的RenderUtils :: isValidPng(std :: istream&)。ld:架構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);
}

我的猜測是您構建了32位版本的libpng,但現在您嘗試將其鏈接到64位代碼。 嘗試file *otool -L *檢查(從內存中)

對不起,大家。。。 我需要鏈接到zlib .....自我注釋.....總是閱讀自述文件....(並非總是如此!)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM