繁体   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