| 01-30-2009, 07:19 PM | #1 |
Not to long ago i tried using sfmpq.dll with visual baisc, probably not the best idea. I'm a bit new to c++ and could anyone give me a little info on how to use .dll's, more specifically sfmpq. So could someone show me an example on how to import, and then use the functions provided within the .dll, with a simple console application, that would just extract one of the files from the mpq. I found something like.... PHP Code:
But it gives me a few errors. "Expected unqualified-id before "if"" "Expected ',' or ';' before if" "[Build error] [main.o] Error 1" |
| 01-30-2009, 08:48 PM | #2 |
You have a missing ; after the first if and an extra one before the second if. |
| 01-30-2009, 09:05 PM | #3 | |
I get even more errors when fixing those. I'd rather not use that example. Quote:
|
| 01-31-2009, 02:51 AM | #4 |
| 01-31-2009, 03:09 AM | #5 |
Yes i went through your code, but it was extra long because it was a windows application, i want to just see a source code for a dos application. sfmpq is also used alot, which is why i chose it. Whats so special about storm lib also? |
| 01-31-2009, 03:12 AM | #6 | |
Quote:
|
| 01-31-2009, 03:14 AM | #7 |
Well, what im looking for is maybe an example of how to make a simple dos application that can extract a random file from the mpq. Hopefully pitzermike sees this. |
| 01-31-2009, 03:30 AM | #8 |
As I sayed strange problems happened to me using that DLL, also, since it's a dynamic DLL you have all the hassle to load the library (LoadLibrary) at run-time and get the function pointer (GetProcAddress). With Storm you link a static library to your executable and dont need to ship any dll with your program. Also I have more familiarity with Storm. |
| 01-31-2009, 03:44 AM | #9 |
I looked at your source code once more (from old link). I managed to compile it in dev c++, though if i click Load Small/Big File, it says "could not read inside the mpq" I have a feeling it's because i didn't link the library like you stated above. I also looked at stormlib what do i use in the god damn .zip, there are about 20 files, what do i use to allow me to use the functions. Thanks to all helpers. |
| 01-31-2009, 04:12 AM | #10 |
Try the StomLib, I've compiled it for you and included it with the headers in a zip. I think Dev c++ have an option in the project setting where you select .lib files to be linked, located it and select StormLibRAS622.lib else it will give you linkin errors -Basically you use a function to open an MPQ (SFileOpenArchive for only reading, SFileCreateArchiveEx for read/write) -Then SFileOpenFileEx to open a given filename inside the MPQ -Get the size with SFileGetFileSize of the file you just opened -And read the file with SFileReadFile |
| 01-31-2009, 04:21 AM | #11 |
I thank you for all of your help, though i'm still trying to figure out how to link a library. Don't forget this thread please, im sure i will have more questions. EDIT: I am so sorry, could you show me a console application example, that successfully extracts a file from an mpq, else i will need to keep messing around for hours. |
| 01-31-2009, 05:35 PM | #12 |
In Dev C++ I wasn't able to compile the sample program that you asked, it doesn't want to link StormLib. Better you get Visual Studio where I can sucefully compile it and show you how it works. Attached the Dev C++ test that I was trying. |
| 01-31-2009, 05:44 PM | #13 |
I have visual studio also. Thanks once again. Don't know how i can thank you. EDIT: A working visual studio example would also be much appreciated, considering the test example isn't working. Sorry to nag. Hopefully it isn't to much trouble. |
| 01-31-2009, 07:58 PM | #14 |
done, in the sample war3map.j is extracted from a .w3x map |
| 01-31-2009, 08:31 PM | #15 |
I cannot thank you enough!! (or can i). Is there anything you need, that i could give you. |
