aMule Forum
English => Compilation problems => Topic started by: Radek on January 11, 2006, 01:19:43 PM
-
I just tried to compile today's snapshot on Win$/MingW and ran into this error
if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/mingw/lib/wx/include/msw-unicode-release-static-2.7 -I/mingw/include/wx-2.7 -D__WXMSW__ -mthreads -I./libs -DNOMINMAX -DUSE_EMBEDDED_CRYPTO -W -Wall -Wshadow -Wundef -O2 -MT libmuleappcommon_a-CFile.o -MD -MP -MF ".deps/libmuleappcommon_a-CFile.Tpo" -c -o libmuleappcommon_a-CFile.o `test -f 'CFile.cpp' || echo './'`CFile.cpp; \
then mv -f ".deps/libmuleappcommon_a-CFile.Tpo" ".deps/libmuleappcommon_a-CFile.Po"; else rm -f ".deps/libmuleappcommon_a-CFile.Tpo"; exit 1; fi
CFile.cpp: In member function `virtual uint64 CFile::GetLength() const':
CFile.cpp:382: error: `_fstat64' was not declared in this scope
CFile.cpp:382: warning: unused variable '_fstat64'
I looked around and found out, that this has to do with the version of MSCVRT.dll. The above code would only compile if said dll has a version > 6.01.
In %windir%\system32 I have a mscvrt.dll with a version >7.0, so I am not quite sure, why gcc believes otherwise, but there might be some other version in a library searchpath I haven't found yet.
I patched the code in CFile.cpp to this$ diff src/CFile.cpp src/CFile.cpp.ORG
381,385d380
< # if ( __MSVCRT_VERSION__ < 0x0601 )
< # warning MSCVRT-Version smaller than 6.01
< struct _stati64 buf;
< if (_fstati64(m_fd, &buf) == -1) {
< # else
388d382
< # endif
and it compiled alright.
After that I ran into some other error, which I will mention in another thread.
One remark: yesterday I installed the new gcc 3.4.5 for MingW from sourceforge. Before that, I had 3.4.2 installed. Could that be the source of the problem?
-
Does _fstati64 exist on all versions? Sadly MSDN did not mention anything about that, but if that is the case, then we can simply use that function instead, AFAICS.
-
In include/sys/stat.h I found this
#if defined (__MSVCRT__)
_CRTIMP int __cdecl _fstati64(int, struct _stati64 *);
_CRTIMP int __cdecl _stati64(const char *, struct _stati64 *);
/* These require newer versions of msvcrt.dll (6.10 or higher). */
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP int __cdecl _fstat64 (int, struct __stat64*);
_CRTIMP int __cdecl _stat64 (const char*, struct __stat64*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
_CRTIMP int __cdecl _wstat(const wchar_t*, struct _stat*);
_CRTIMP int __cdecl _wstati64 (const wchar_t*, struct _stati64*);
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP int __cdecl _wstat64 (const wchar_t*, struct __stat64*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#define _WSTAT_DEFINED
#endif /* _WSTAT_DEFIND */
#endif /* __MSVCRT__ */
So it seems to be the fact, that the 'i'-variants are there in every version. And my resulting amulegui.exe has it's dependency against the newer (7.01) version of msvcrt.dll in Window's system32 folder. So - it did work.
What I don't understand is, why was my msvcrt.dll seen as version < 6.01 by gcc? Any ideas about that?
-
I have no idea, I'm afraid. Maybe the mingw devs can help.
-
Hmmm.... today I ran in a similar kind of error:
CFile.cpp: In member function `virtual uint64 CFile::GetLength() const':
CFile.cpp:382: error: `_fstat64' undeclared (first use this function)
CFile.cpp:382: error: (Each undeclared identifier is reported only once for each function it appears in.)
make[3]: *** [libmuleappcommon_a-CFile.o] Error 1
Now just some more info:
I compiled sucessfully (and even working!) on 20060109 sources
I haven't changed mingw/msys component since then
I haven't installed any software on my machine
It's also noticeable that CFile.cpp has a modify date of 2006 Jan 10, and I haven't try to compile since Jan 09...
I would like to try patching the file as shown by Radek, but I am not sure about how to do it (diff output syntax is quite obscure to me). The unmodified(?) lines at pos 381 of my Cfile.cpp are
struct __stat64 buf;
if (_fstat64(m_fd, &buf) == -1) {
while they should read (if I read well the diff output)
struct _stati64 buf;
if (_fstati64(m_fd, &buf) == -1) {
The additional _ and the fstat instead of fstati makes me think that I can't simply copy the patch listed to have working code...
Someone can help me?
Linux box has already finished compiling 20060113, and until I'm able to patch this source I won't be able to control amuled... (I'll have again to stick with amuleweb) :P
Thanks!
-
This is the complete hotfix in CFile.cpp with the surrounding code
uint64 CFile::GetLength() const
{
MULE_VALIDATE_STATE(IsOpened(), wxT("CFile: Cannot get length of closed file."));
#ifdef __WXMSW__
# if ( __MSVCRT_VERSION__ < 0x0601 )
# warning MSCVRT-Version smaller than 6.01
struct _stati64 buf;
if (_fstati64(m_fd, &buf) == -1) {
# else
struct __stat64 buf;
if (_fstat64(m_fd, &buf) == -1) {
# endif
#else
struct stat buf;
if (fstat(m_fd, &buf) == -1) {
#endif
throw CIOFailureException(wxString(wxT("Failed to retrieve length of file: ")) + wxSysErrorMsg());
}
return buf.st_size;
}
Should work out of the (copy and paste) box...
-
Thanks!
Now I was able to properly patch the source!
amulegui.exe compiles fine now, and it also works (at least connect and search works :P )
I hope the patch will be soon included in the source tree... I won't like to do that everytime I compile from CVS again :D
-
Thanks. I'll apply your patch.
Btw, I take it that the stat64 usage in FileFunctions.cpp compiles ok?
Also, if you dont mind, could you try running 'make check' (only need to ) to ensure that everything works ok with this change? I'm afraid I'm having trouble with my vmwared widows atm, so I cannot test myself. =/
-
In today's snapshot (20060113) I only needed to keep my patched version of CFile.cpp. I observed no other problems while compiling.
I ran "make check", as you suggested.==================
All 5 tests passed
==================
-
Thanks.