PDA

View Full Version : Works on 64bit doesn't on 32 bit



daniel_dm
11th June 2013, 15:25
Hi everyone,
i'm developing with qt by 6 months.
i've just developed a dll under windows using qt creator 2.7.0 with qt 5.02 compiling with MinGW 4.7 32bit and then i link it in vb.net project with a wrapper made in c#.
The library use stcall to face the functions to the wrapper and my application goes fine on 64bit operating system (windows 7 and windows 8 tested)
if i run my application under windows xp 32bit operating systems i receive the following error:


System.DllNotFoundException: Unable to load DLL 'QTRender.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at dmg.renderImport.DllInterface.DrawTextGiottoFix(By te[] c, Int32& width, Int32& height, Single& fontSize, Int32 letterSpacing, Int32 wordSpacing, Int32 fontWeight, Byte[] Testo, Int32 lenTesto, Byte[] fontName, Int32 lenFontName, Int32 Rfore, Int32 Gfore, Int32 Bfore, Int32 Afore, Int32 Rshadow, Int32 Gshadow, Int32 Bshadow, Int32 Ashadow, QthAlign hAlign, QtvAlign vAlign)
at QTRenderWrapper.Wrapper.DrawImageFix(String Testo, Int32& width, Int32& height, Single& fontSize, Int32 letterSpacing, Int32 wordSpacing, Int32 fontWeight, String Fontname, Int32 lenFontName, Int32 Rfore, Int32 Gfore, Int32 Bfore, Int32 Afore, Int32 Rshadow, Int32 Gshadow, Int32 Bshadow, Int32 Ashadow, QthAlign hAlign, QtvAlign vAlign)

i can't understand why, it's almost a month i'm crashing my head upon this!
please someone could help me?
tell me if you need other details.

thank you

saman_artorious
13th June 2013, 09:48
Since C# programs run in AnyCPU mode, it automatically loads 64 bit dlls under 64 bit OS and 32 bit dlls under 32 bit OS.

Compile the DLL with a 32 bit compiler and put 32 QT Dlls with it.

daniel_dm
18th July 2013, 14:24
Hi Saman,
thank you for your answer, i've not been at work so i didn't read your reply.
Compiling with a 32 bit compiler is what i've done for first, i'm using Qt 5.0.2 MinGW 32bit
I don't understand from your reply if i have to put in my application folder both the 32 and 64 bit compiled dll.
Do i need two versions of the same library?
I thought about some type conversions of the parameter i'm passing to the library but i'm using only pointers, int and chars. I don't know where it could be fail.
Follow parts of my code
QTR.pro


#-------------------------------------------------
#
# Project created by QtCreator 2012-11-13T11:23:02
#
#-------------------------------------------------

TARGET = QTR
TEMPLATE = lib
QMAKE_CFLAGS += /Gz QMAKE_CXXFLAGS += /Gz
DEFINES += QTR_LIBRARY

SOURCES += qtr.cpp

HEADERS += qtr.h\
QTR_global.h

symbian {
MMP_RULES += EXPORTUNFROZEN
TARGET.UID3 = 0xE3A9118A
TARGET.CAPABILITY =
TARGET.EPOCALLOWDLLDATA = 1
addFiles.sources = QTR.dll
addFiles.path = !:/sys/bin
DEPLOYMENT += addFiles
}

unix:!symbian {
maemo5 {
target.path = /opt/usr/lib
} else {
target.path = /usr/lib
}
INSTALLS += target
}

CONFIG += QwtDll


win32 {
QMAKE_LFLAGS += -static-libgcc
}




header file



#-------------------------------------------------
#
# Project created by QtCreator 2012-11-13T11:23:02
#
#-------------------------------------------------

TARGET = QTR
TEMPLATE = lib
QMAKE_CFLAGS += /Gz QMAKE_CXXFLAGS += /Gz
DEFINES += QTR_LIBRARY

SOURCES += qtr.cpp

HEADERS += qtr.h\
QTR_global.h

symbian {
MMP_RULES += EXPORTUNFROZEN
TARGET.UID3 = 0xE3A9118A
TARGET.CAPABILITY =
TARGET.EPOCALLOWDLLDATA = 1
addFiles.sources = QTR.dll
addFiles.path = !:/sys/bin
DEPLOYMENT += addFiles
}

unix:!symbian {
maemo5 {
target.path = /opt/usr/lib
} else {
target.path = /usr/lib
}
INSTALLS += target
}

CONFIG += QwtDll


win32 {
QMAKE_LFLAGS += -static-libgcc
}



can anybody help?
thank you in advance
daniel

daniel_dm
5th August 2013, 13:24
Hi
posting again some news about my tests.
The only machine where i can't use this dll is Windows XP on 32 bit processors.
I can't understand why this happens.
following my c# wrapper code



thank you in adavance to anybody could help me



public class DllInterface
{
[DllImport(@"QTRender.dll", EntryPoint = "??0QTRender@@QAE@XZ")]
public static extern int Init();
[DllImport(@"QTRender.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int DrawTextGiotto([Out] byte[] c, [In][Out] ref int width, [In][Out] ref int height, [In][Out] ref float fontSize, int letterSpacing, int wordSpacing, int fontWeight, [In] byte[] Testo, int lenTesto, [In] byte[] fontName, int lenFontName, int Rfore, int Gfore, int Bfore, int Afore, int Rshadow, int Gshadow, int Bshadow, int Ashadow, QthAlign hAlign, QtvAlign vAlign);

[DllImport(@"QTRender.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int DrawTextInSquare([Out] byte[] c, [In][Out] ref int width, [In][Out] ref int height, [In][Out] ref float fontSize, int letterSpacing, int wordSpacing, int fontWeight, [In] byte[] Testo, int lenTesto, [In] byte[] fontName, int lenFontName, int Rfore, int Gfore, int Bfore, int Afore, int Rshadow, int Gshadow, int Bshadow, int Ashadow, QthAlign hAlign, QtvAlign vAlign);

[DllImport(@"QTRender.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int DrawTextGiottoFix([Out] byte[] c, [In][Out] ref int width, [In][Out] ref int height, [In][Out] ref float fontSize, int letterSpacing, int wordSpacing, int fontWeight, [In] byte[] Testo, int lenTesto, [In] byte[] fontName, int lenFontName, int Rfore, int Gfore, int Bfore, int Afore, int Rshadow, int Gshadow, int Bshadow, int Ashadow, QthAlign hAlign, QtvAlign vAlign);
}