release build causes errors

Hello!
I have set of projects which consist of dynamic library
(lets call it libMain), set of executables (exes) and set of dynamic
libraries (libs).
Both exes and libs use libMain.
Debug build causes no errors.
Release build causes similar errors in libs that looks like:

<one of libs> fatal error LNK1194: cannot delay-load '<libMain>' due
to import of data symbol '"__declspec(dllimport) const
<libMainClass>::`vftable'" (__imp_??_7<libMainClass>@@6B@)'; link
without /DELAYLOAD:<libMain>

<libMainClass> is one of two interface (virtual abstract ) classes declared in libMain this way:
class QTS_EXPORTQTS <libMainClass>
{
public:
virtual ~<libMainClass>() {};
virtual QString text() = 0;
<other virtual funcs just like text()>
};

QTS_EXPORTQTS defined as __declspec(dllexport) when building library and __declspec(dllimport) when linking against it.

Note, release build causes no errors in libMain and exes.
[1099 byte] By [a550ee] at [2007-11-20 1:38:47]
# 1 Re: release build causes errors
Are you sure your linker settings for the Release build are correct?

Viggy
MrViggy at 2007-11-10 23:17:46 >
# 2 Re: release build causes errors
Go into the project settings and cut and paste the 'command line' settings for C/C++ properties and Linker properties into a Notepad session. Compare the two. You'll likely spot a difference.
Mike Harnad at 2007-11-10 23:18:53 >
# 3 Re: release build causes errors
I've compared commands for both compiler and linker. Here are they:
1. debug

compiler
=======
/I "..\libQts" /I "C:\Qt\3.3.4\include"
/I "." /I "C:\Qt\3.3.4\mkspecs\win32-msvc.net"
/D "_WINDOWS" /D "UNICODE" /D "WIN32" /D "QTS_WIN32"
/D "QTS_QTS" /D "QTS_MAKEQTSREPORT"
/D "QT_DLL" /D "QT_THREAD_SUPPORT" /D "_WINDLL"
/Gm /MDd /GR /Fo".\\" /Fd".\\" /W3 /nologo /c /Zi /TP

linker
======
/OUT:"..\..\lib\QtsReport.dll" /NOLOGO /LIBPATH:"../../lib"
/LIBPATH:"C:\Qt\3.3.4\lib" /DLL /DELAYLOAD:"Qts.dll"
/DEBUG /SUBSYSTEM:WINDOWS /BASE:"0x39D00000" qt-mt334.lib Qts.lib
delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
imm32.lib winmm.lib wsock32.lib winspool.lib delayimp.lib
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib DelayImp.lib

2.release

compiler
========
/O1 /I "..\libQts" /I "C:\Qt\3.3.4\include"
/I "." /I "C:\Qt\3.3.4\mkspecs\win32-msvc.net"
/D "QT_NO_DEBUG" /D "NDEBUG"
/D "_WINDOWS" /D "UNICODE" /D "WIN32" /D "QTS_WIN32"
/D "QTS_QTS" /D "QTS_MAKEQTSREPORT"
/D "QT_DLL" /D "QT_THREAD_SUPPORT" /D "_WINDLL"
/FD /MD
/GR /Fo".\\" /Fd".\\" /W3 /nologo /c /TP

linker
======
/OUT:"..\..\lib\QtsReport.dll" /NOLOGO /LIBPATH:"../../lib"
/LIBPATH:"C:\Qt\3.3.4\lib" /DLL /DELAYLOAD:"Qts.dll"
/DELAYLOAD:"comdlg32.dll" /DELAYLOAD:"oleaut32.dll" /DELAYLOAD:"winmm.dll" /DELAYLOAD:"wsock32.dll" /DELAYLOAD:"winspool.dll"
/SUBSYSTEM:WINDOWS /BASE:"0x39D00000" qt-mt334.lib Qts.lib
delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
imm32.lib winmm.lib wsock32.lib winspool.lib delayimp.lib
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib DelayImp.lib

Looks pretty similar.

I import dozens of classes from Qts.dll but all release targets fail on only two virtual abstract classes. Moreover, theres "vftable" word in error message. As far as I know its a virtual function table :)
Maybe It somehow related to fact theese two classes are abstract.
a550ee at 2007-11-10 23:19:51 >
# 4 Re: release build causes errors
So, what is your question? How to fix it or why does it fail?
This thread here (http://www.tech-archive.net/Archive/VC/microsoft.public.vc.language/2004-09/0456.html) suggests that some optimization (likely, disabled in your DEBUG build) affect the way vtable of abstract class is exported.
If you just want to fix it - remove /DELEAY load switch for that dll (as your linker recommended).
VladimirF at 2007-11-10 23:20:51 >
# 5 Re: release build causes errors
Thanks VladimirF!
I was using delayload not concerning what it stands for. As I subclass some classess imported from dll , I think delayload is not necessary.
a550ee at 2007-11-10 23:21:50 >