<div dir="ltr">I'm just linking with -lphysfs, like you said.  I don't have MSYS.  The only source file I modified was physfs.c, I didn't add any.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Aug 27, 2014 at 7:45 AM, Tim Čas <span dir="ltr"><<a href="mailto:darkuranium@gmail.com" target="_blank">darkuranium@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How are you using libphysfs.a? I've often found that linking with just<br>
-lphysfs tends to make MinGW link with the DLL instead of the library.<br>
<br>
If you have MSYS, you can also try this to find out if the DLL exports<br>
the symbol (which would indicate that the problem is elsewhere):<br>
$ nm libphysfs.dll | grep openRead<br>
<br>
Oh and, I just had a thought --- when you added PHYSFS_openReadMulti,<br>
did you create any new source files? If you did, you have to run cmake<br>
again for it to recognize the new files? It is entirely possible that<br>
it's not compiling in said new file (though that wouldn't quite<br>
explain why the symbol exists in the static library).<br>
<div class="HOEnZb"><div class="h5"><br>
On 27 August 2014 15:21, Haydn Harach <<a href="mailto:hharach@gmail.com">hharach@gmail.com</a>> wrote:<br>
> It creates "libphysfs.a", "libphysfs.dll", and "libphysfs.dll.a"<br>
><br>
> I've tried using both the .dll and the non-.dll version of the .a library,<br>
> they both have the issues.  Interestingly, when using libphysfs.a, it still<br>
> requires libphysfs.dll, even before I started modifying the source code.<br>
><br>
><br>
> On Wed, Aug 27, 2014 at 7:17 AM, Tim Čas <<a href="mailto:darkuranium@gmail.com">darkuranium@gmail.com</a>> wrote:<br>
>><br>
>> And did you also compile the DLLs, or did you only compile the static<br>
>> (*.a) library? MinGW tends to create one file for static builds (foo.a<br>
>> or libfoo.a) and two files for dynamic builds ({lib,}foo.dll.a and<br>
>> {lib,}foo.dll) --- it seems that you've perhaps only created the<br>
>> static library?<br>
>><br>
>> On 27 August 2014 13:05, Haydn Harach <<a href="mailto:hharach@gmail.com">hharach@gmail.com</a>> wrote:<br>
>> > Yes, I did replace the dll's.  From what I gather,<br>
>> > `PHYSFS_openReadMulti` is<br>
>> > present in `physfs.a` but not in `physfs.dll`, and `PHYSFS_closeList` is<br>
>> > not<br>
>> > present in `physfs.a` (and presumably not in `physfs.dll`, either).<br>
>> ><br>
>> > I'm compiling both physfs and my app using MinGW-W64.<br>
>> ><br>
>> ><br>
>> > On Wed, Aug 27, 2014 at 3:39 AM, Tim Čas <<a href="mailto:darkuranium@gmail.com">darkuranium@gmail.com</a>> wrote:<br>
>> >><br>
>> >> Did you replace the DLLs after compiling? The application might still<br>
>> >> be<br>
>> >> using the old one if you forgot to do that.<br>
>> >><br>
>> >><br>
>> >> On 27 August 2014 10:10, Haydn Harach <<a href="mailto:hharach@gmail.com">hharach@gmail.com</a>> wrote:<br>
>> >>><br>
>> >>> PHYSFS_openReadMulti compiles just fine, but then my app crashes<br>
>> >>> because<br>
>> >>> it can't find it in physfs.dll.  So, it found it in the .a, but not in<br>
>> >>> the<br>
>> >>> .dll?  what am I doing wrong compiling physfs? >.<<br>
>> >>><br>
>> >>><br>
>> >>> On Tue, Aug 26, 2014 at 9:51 AM, Haydn Harach <<a href="mailto:hharach@gmail.com">hharach@gmail.com</a>><br>
>> >>> wrote:<br>
>> >>>><br>
>> >>>> Now I'm having trouble rebuilding the project.  I'm trying to use a<br>
>> >>>> code::blocks project which I generated with cmake, changing only the<br>
>> >>>> 2 files<br>
>> >>>> (physfs.c and physfs.h).  It compiles and builds just fine, but I'm<br>
>> >>>> getting<br>
>> >>>> "undefined reference to PHYSFS_closeList" now.  What did I do wrong?<br>
>> >>>><br>
>> >>>><br>
>> >>>> On Mon, Aug 25, 2014 at 6:55 PM, Haydn Harach <<a href="mailto:hharach@gmail.com">hharach@gmail.com</a>><br>
>> >>>> wrote:<br>
>> >>>>><br>
>> >>>>> Alrighty, here are the additions I've made to my physfs.c:<br>
>> >>>>><br>
>> >>>>> PHYSFS_File **PHYSFS_openReadMulti(const char *_fname)<br>
>> >>>>> {<br>
>> >>>>>     char *fname;<br>
>> >>>>>     size_t len;<br>
>> >>>>><br>
>> >>>>>     BAIL_IF_MACRO(_fname == NULL, ERR_INVALID_ARGUMENT, 0);<br>
>> >>>>>     len = strlen(_fname) + 1;<br>
>> >>>>>     fname = (char *) __PHYSFS_smallAlloc(len);<br>
>> >>>>>     BAIL_IF_MACRO(fname == NULL, ERR_OUT_OF_MEMORY, 0);<br>
>> >>>>><br>
>> >>>>>     FileHandle** ret = NULL;<br>
>> >>>>>     unsigned int retcount = 0;<br>
>> >>>>><br>
>> >>>>>     if (sanitizePlatformIndependentPath(_fname, fname))<br>
>> >>>>>     {<br>
>> >>>>>         int fileExists = 0;<br>
>> >>>>>         DirHandle *i = NULL;<br>
>> >>>>>         fvoid *opaque = NULL;<br>
>> >>>>><br>
>> >>>>>         __PHYSFS_platformGrabMutex(stateLock);<br>
>> >>>>><br>
>> >>>>>         GOTO_IF_MACRO(!searchPath, ERR_NO_SUCH_PATH, openReadEnd);<br>
>> >>>>><br>
>> >>>>>         /* !!! FIXME: Why aren't we using a for loop here? */<br>
>> >>>>>         i = searchPath;<br>
>> >>>>><br>
>> >>>>>         do<br>
>> >>>>>         {<br>
>> >>>>>             char *arcfname = fname;<br>
>> >>>>>             if (verifyPath(i, &arcfname, 0))<br>
>> >>>>>             {<br>
>> >>>>>                 opaque = i->funcs->openRead(i->opaque, arcfname,<br>
>> >>>>> &fileExists);<br>
>> >>>>>                 if (opaque)<br>
>> >>>>>                 {<br>
>> >>>>>                    // We found a valid file, let's prepare it.<br>
>> >>>>>                    FileHandle* h =<br>
>> >>>>> (FileHandle*)allocator.Malloc(sizeof(FileHandle));<br>
>> >>>>>                    if (h == NULL)<br>
>> >>>>>                    {<br>
>> >>>>>                       i->funcs->fileClose(opaque);<br>
>> >>>>>                         GOTO_MACRO(ERR_OUT_OF_MEMORY, openReadEnd);<br>
>> >>>>>                    }<br>
>> >>>>>                    memset(h, 0, sizeof(FileHandle));<br>
>> >>>>>                    h->opaque = opaque;<br>
>> >>>>>                    h->forReading = 1;<br>
>> >>>>>                    h->dirHandle = i;<br>
>> >>>>>                    h->funcs = i->funcs;<br>
>> >>>>>                    h->next = openReadList;<br>
>> >>>>>                    openReadList = h;<br>
>> >>>>><br>
>> >>>>>                      // Add the file to the list<br>
>> >>>>>                      FileHandle** temp =<br>
>> >>>>> (FileHandle**)allocator.Malloc(sizeof(FileHandle) * (retcount + 1));<br>
>> >>>>>                      if (temp == NULL)<br>
>> >>>>>                      {<br>
>> >>>>>                         allocator.Free(h);<br>
>> >>>>>                         i->funcs->fileClose(opaque);<br>
>> >>>>>                         GOTO_MACRO(ERR_OUT_OF_MEMORY, openReadEnd);<br>
>> >>>>>                      }<br>
>> >>>>>                      if (ret != NULL)<br>
>> >>>>>                      {<br>
>> >>>>>                         memcpy(temp, ret, sizeof(FileHandle) *<br>
>> >>>>> retcount);<br>
>> >>>>>                         allocator.Free(ret);<br>
>> >>>>>                      }<br>
>> >>>>>                      temp[retcount] = h;<br>
>> >>>>>                      ++retcount;<br>
>> >>>>>                      ret = temp;<br>
>> >>>>>                 }<br>
>> >>>>>             } /* if */<br>
>> >>>>>             i = i->next;<br>
>> >>>>>         } while ((i != NULL) && (!fileExists));<br>
>> >>>>><br>
>> >>>>>         // Add a null terminator to the list<br>
>> >>>>>         if (ret != NULL)<br>
>> >>>>>         {<br>
>> >>>>>            FileHandle** temp =<br>
>> >>>>> (FileHandle**)allocator.Malloc(sizeof(FileHandle) * (retcount + 1));<br>
>> >>>>>            if (temp == NULL)<br>
>> >>>>>                GOTO_MACRO(ERR_OUT_OF_MEMORY, openReadEnd);<br>
>> >>>>><br>
>> >>>>>             memcpy(temp, ret, sizeof(FileHandle) * retcount);<br>
>> >>>>>             allocator.Free(ret);<br>
>> >>>>><br>
>> >>>>>             temp[retcount] = NULL;<br>
>> >>>>>             ret = temp;<br>
>> >>>>>         }<br>
>> >>>>><br>
>> >>>>>         openReadEnd:<br>
>> >>>>>         __PHYSFS_platformReleaseMutex(stateLock);<br>
>> >>>>>     } /* if */<br>
>> >>>>><br>
>> >>>>>     __PHYSFS_smallFree(fname);<br>
>> >>>>>     return ret;<br>
>> >>>>> } /* PHYSFS_openReadMulti */<br>
>> >>>>><br>
>> >>>>> int PHYSFS_closeList(PHYSFS_file** list)<br>
>> >>>>> {<br>
>> >>>>>    int retval = 1;<br>
>> >>>>><br>
>> >>>>>    for (PHYSFS_file** i = list; *i != NULL; ++i)<br>
>> >>>>>    {<br>
>> >>>>>       if (PHYSFS_close(*i) == 0)<br>
>> >>>>>          retval = 0;<br>
>> >>>>>    }<br>
>> >>>>><br>
>> >>>>>    allocator.Free(list);<br>
>> >>>>>    return retval;<br>
>> >>>>> }<br>
>> >>>>><br>
>> >>>>> Is there anything not immediately obvious that I'm missing?<br>
>> >>>>><br>
>> >>>>><br>
>> >>>>> On Mon, Aug 25, 2014 at 6:11 PM, Edward Rudd <urkle@outoforder.cc><br>
>> >>>>> wrote:<br>
>> >>>>>><br>
>> >>>>>> On Aug 25, 2014, at 8:06 PM, Haydn Harach <<a href="mailto:hharach@gmail.com">hharach@gmail.com</a>><br>
>> >>>>>> wrote:<br>
>> >>>>>><br>
>> >>>>>> > Looking at PHYSFS_openRead() in physfs.c, I've found this little<br>
>> >>>>>> > snippet:<br>
>> >>>>>> ><br>
>> >>>>>> > do<br>
>> >>>>>> >         {<br>
>> >>>>>> >             char *arcfname = fname;<br>
>> >>>>>> >             if (verifyPath(i, &arcfname, 0))<br>
>> >>>>>> >             {<br>
>> >>>>>> >                 opaque = i->funcs->openRead(i->opaque, arcfname,<br>
>> >>>>>> > &fileExists);<br>
>> >>>>>> >                 if (opaque)<br>
>> >>>>>> >                     break;<br>
>> >>>>>> >             } /* if */<br>
>> >>>>>> >             i = i->next;<br>
>> >>>>>> >         } while ((i != NULL) && (!fileExists));<br>
>> >>>>>> ><br>
>> >>>>>> > Now, from what I can see, this loop goes through all the paths,<br>
>> >>>>>> > and<br>
>> >>>>>> > the first one that satisfies the function and returns some data<br>
>> >>>>>> > (from the<br>
>> >>>>>> > openRead function) and causes 'opaque' to not be NULL, and thus<br>
>> >>>>>> > breaks out<br>
>> >>>>>> > of the loop.<br>
>> >>>>>> ><br>
>> >>>>>> > So, if I replaced "if (opaque) break;" with "if (opaque)<br>
>> >>>>>> > someVector.emplace_back(opaque, i);", then did some cleanup to<br>
>> >>>>>> > ensure that I<br>
>> >>>>>> > have a vector of FileHandle's instead of one, and return that,<br>
>> >>>>>> > this should<br>
>> >>>>>> > be exactly what I'm looking for, yes?<br>
>> >>>>>><br>
>> >>>>>> More or less, yes that would be exactly what you were looking for.<br>
>> >>>>>> _______________________________________________<br>
>> >>>>>> physfs mailing list<br>
>> >>>>>> <a href="mailto:physfs@icculus.org">physfs@icculus.org</a><br>
>> >>>>>> <a href="http://icculus.org/mailman/listinfo/physfs" target="_blank">http://icculus.org/mailman/listinfo/physfs</a><br>
>> >>>>><br>
>> >>>>><br>
>> >>>><br>
>> >>><br>
>> >>><br>
>> >>> _______________________________________________<br>
>> >>> physfs mailing list<br>
>> >>> <a href="mailto:physfs@icculus.org">physfs@icculus.org</a><br>
>> >>> <a href="http://icculus.org/mailman/listinfo/physfs" target="_blank">http://icculus.org/mailman/listinfo/physfs</a><br>
>> >>><br>
>> >><br>
>> >><br>
>> >> _______________________________________________<br>
>> >> physfs mailing list<br>
>> >> <a href="mailto:physfs@icculus.org">physfs@icculus.org</a><br>
>> >> <a href="http://icculus.org/mailman/listinfo/physfs" target="_blank">http://icculus.org/mailman/listinfo/physfs</a><br>
>> >><br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > physfs mailing list<br>
>> > <a href="mailto:physfs@icculus.org">physfs@icculus.org</a><br>
>> > <a href="http://icculus.org/mailman/listinfo/physfs" target="_blank">http://icculus.org/mailman/listinfo/physfs</a><br>
>> ><br>
>> _______________________________________________<br>
>> physfs mailing list<br>
>> <a href="mailto:physfs@icculus.org">physfs@icculus.org</a><br>
>> <a href="http://icculus.org/mailman/listinfo/physfs" target="_blank">http://icculus.org/mailman/listinfo/physfs</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> physfs mailing list<br>
> <a href="mailto:physfs@icculus.org">physfs@icculus.org</a><br>
> <a href="http://icculus.org/mailman/listinfo/physfs" target="_blank">http://icculus.org/mailman/listinfo/physfs</a><br>
><br>
_______________________________________________<br>
physfs mailing list<br>
<a href="mailto:physfs@icculus.org">physfs@icculus.org</a><br>
<a href="http://icculus.org/mailman/listinfo/physfs" target="_blank">http://icculus.org/mailman/listinfo/physfs</a><br>
</div></div></blockquote></div><br></div>