I am trying to build this project, which is basically an extractor for specific .rom files. As someone with close to zero experience in coding, I am having one issue after another trying to build it.
The project description says it requires zlibstat.lib from zlib in order to build it, so I got the latest zlib, opened it on VS2019, followed these instructions, and built everything, included the required zlibstat.lib.
After opening the project's sln and figuring where to put the zlib related files, I tried to build but it gave me this error in fs.obj: "LNK2019: unresolved external symbol _uncompress referenced in function "int __cdecl run_extract(char *)" (?run_extract@@YAHPAD@Z)". This is how far google and my two brain cells has led me to.
I am not exactly sure what I should do to solve this but apparently is has something to do with the run_extract function:
fs.h
#pragma once
#include <iostream>
#include <fstream>
#include "defs.h"
#include <zlib.h>
#pragma comment(lib, "zlibstat.lib")
#include <shlwapi.h>
#pragma comment(lib,"shlwapi.lib")
int run_extract(char *);
and fs.cpp
int run_extract(char *path)
{
std::fstream test;
test.open(path, std::ios::in | std::ios::binary);
if (!test) return -1;
size_t file_size;
test.seekg(0, std::ios::end);
file_size = test.tellg();
test.seekg(0, std::ios::beg);
unsigned char *buffer = new unsigned char [file_size];
test.read((char*)buffer, file_size);
test.close();
jrm_rom_header *ptrHeader = (jrm_rom_header*)buffer;
unsigned long indexLen = ptrHeader->count_index * sizeof(jrm_rom_file_index);
unsigned char *index = new unsigned char [indexLen];
uncompress(index, &indexLen, (const Bytef*)(buffer + ptrHeader->pos_index), ptrHeader->size_index); // use zlib
jrm_rom_file_index *ptrIndex = (jrm_rom_file_index*)index;
unsigned char key = 0;
char *path_out = new char[0x100];
unsigned long ypos = 0, x = 0;
for (x = 0; x<ptrHeader->count_index; x++)
{
key = (ptrIndex->key & 0xff) ^ (ptrIndex->key >> 8 & 0xff) ^ (ptrIndex->key >> 16 & 0xff) ^ (ptrIndex->key >> 24 & 0xff);
get_file_path(path_out, ptrIndex->file_path);
// printf("%04d: file_name = %s\n file_start = 0x%08x, file_size = 0x%08x, key = 0x%02x\n", x, path_out, ptrIndex->pos_start, ptrIndex->size_file, key);
printf("%s: %d bytes.\n", path_out, ptrIndex->size_file);
for (ypos = 0; ypos < ptrIndex->pos_delta; ypos++)
buffer[ypos + ptrIndex->pos_start] ^= key;
try_create_directory(path_out);
test.open(path_out, std::ios::binary | std::ios::out);
test.write((char*)buffer + ptrIndex->pos_start, ptrIndex->pos_delta);
test.close();
ptrIndex++;
}
delete[]path_out;
delete[]index;
delete[]buffer;
return 0;
}
I thought the problems would go away if I used the same Visual Studio version the project was made, so I installed the Visual C++ 2008 and an older version of zlib, only to end up having the exact same error.
Sorry if I am being dumb and having this entire situation poorly written.