0

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.

Lazard
  • 1
  • So you building zlib from scratch right? I built them both from scratch and it all worked fine for me. What configuration of zlib are you building? I would suggest "LIB Debug" or "LIB Release" – Richard Nixon Aug 06 '20 at 08:04
  • I went for Release, as the instructions said. Is there any other change not mentioned in the instructions that I should be aware of? – Lazard Aug 06 '20 at 09:49
  • Nothing I can think of. I used VS2015 btw. – Richard Nixon Aug 06 '20 at 16:42
  • Tried building using a prebuilt zlib but it still gives me same error, perhaps there's something I have to change in the code? I am no programmer, all I just wanted is the end product of this project... *sighs* – Lazard Aug 07 '20 at 03:10

0 Answers0