The following problem occurs when porting the Cyrus SASL (cyrus-sasl-2.1.23) Library (Compiled using mingw ):
fu000001.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname'fu000004.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname'fu000006.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname'fu000008.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname'nmth000000.o:(.idata$4+0x0): undefined reference to `_nm___iob'collect2: ld returned 1 exit statusmingw32-make[2]: *** [debug\libsasl.dll] Error 1mingw32-make[1]: *** [debug] Error 2mingw32-make: *** [sub-lib-make_default-ordered] Error 2The process "E:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
The following describes the solution process:
1) First, search on the Internet: see how others solve the problem. There are dozens of posts about this issue, most of which are not for any reason. Some people say that the order of the connected database is incorrect. I adjusted the order of the connected database for half a day, but none of them worked. In addition, various possible libraries are not valid.
win32: {# LIBS += -lws2_32 -ladvapi32 -lmingw32 LIBS += -lmsvcrt -ladvapi32 -lws2_32}
2) It seems that we have to perform addition and subtraction to find out the location of the problematic code. This function library is highly dependent and cannot locate the problem by removing a. c file. So I had to find the most likely problematic file and remove the implementation code of the function in sequence, and then try to compile it until the above link problem disappears. After the problem disappears, the removed code is restored and compiled again to locate the problem. After several attempts, I finally found the problem:
fprintf(stderr, "%s", prompt); (void) fflush(stderr); for (p=pbuf; (c = _getch())!=13 && c!=EOF;) { if (p < &pbuf[sizeof(pbuf)-1]) *p++ = (char) c; } *p = '\0'; fprintf(stderr, "\n"); (void) fflush(stderr);
Because of symbolsStderr. View its definition:
#define stderr (&__iob_func()[2])
In the stdio. h file of vs2005, it is no wonder that msvcrt is used. The specific problem here is that stderr is not involved. The perror function is used to replace the fprintf function and stderr function temporarily. That is:
#ifdef WIN32 perror(prompt);#else fprintf(stderr, "%s", prompt); (void) fflush(stderr);#endif for (p=pbuf; (c = _getch())!=13 && c!=EOF;) { if (p < &pbuf[sizeof(pbuf)-1]) *p++ = c; } *p = '\0';#ifdef WIN32 perror("\n");#else fprintf(stderr, "\n"); (void) fflush(stderr);#endif
This link problem disappears.
It should be noted that this library has no problem in vs compilation (I did not use the ntmakefile file that comes with this library, but created. Pro under qtcreator and compiled it with vs2005 ). Since another project of mine uses pthread and mingw for compilation, this library also needs mingw for compilation.
Questions left over: it is unclear why mingw uses the stdio. h file of Vs and how to avoid referencing the header file of vs. If you are interested, you can study it. If you want to solve the problem, you may wish to provide feedback.