gpt4 book ai didi

C++ libPNG - 简单的初始化错误

转载 作者:太空宇宙 更新时间:2023-11-04 14:15:23 25 4
gpt4 key购买 nike

我在尝试编译时遇到以下错误....

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)

我的代码如下:

//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 * 检查(从内存中)

关于C++ libPNG - 简单的初始化错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11670371/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com