How do I create an In Process COM server?



  • Hi

    I am totally new to QT and am having a problem... I need to be able to create a QT control and use it as an in process activex server in a windows 32 application written in Delphi as a legacy application requires a new UI.

    I have sucessfully compiled the simpleax example project that comes with QT as an out of process server (.exe) but am unable to modify the pro file to get it compiling correctly as a windows COM dll.
    <br>
    The pro file I am using is as follows

    TEMPLATE = lib
    TARGET = simpleax

    CONFIG += activeqt warn_off qaxserver dll

    SOURCES = main.cpp
    DEF_FILE = $$QT_SOURCE_TREE/src/activeqt/control/qaxserver.def
    RC_FILE = $$QT_SOURCE_TREE/src/activeqt/control/qaxserver.rc

    target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/simple
    sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS simple.pro
    sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt/simple
    INSTALLS += target sources

    I am getting numerous errors, the current one being unable to find main.moc, which is included in main.cpp, the error is "moc: Too many input files specified". I am not sure why that error started happening...

    the moc command line is as follows, something does not appear to be correct, I think the folder name after the last -I is incorrect. How do I change this?

    C:\qt\QT_4_6_2_WIN32\bin\moc.exe .\main.cpp -o .\tmp\moc\Debug_shared\main.moc -D_WINDLL -D_WINDOWS -DQAXSERVER -DQT_CORE_LIB -DQT_DLL -DQT_GUI_LIB -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DUNICODE -DWIN32 Files\Microsoft -IC:\qt\QT_4_6_2_WIN32\include -IC:\qt\QT_4_6_2_WIN32\include\ActiveQt -IC:\qt\QT_4_6_2_WIN32\include\QtCore -IC:\qt\QT_4_6_2_WIN32\include\QtGui -IC:\qt\QT_4_6_2_WIN32\mkspecs\win32-msvc2005 -I.\tmp\moc\Debug_shared -I.\tmp\moc\debug_shared -Ic:\Program Studio\VC98\include Visual

    I have searched the internet and have not found a solution, I think that I have the correct settings in my PRO file

    Any help would be appreciated

    Thanks

    Dave



  • This may sound like a weird solution, but I ran into a similar issue once and what I had to do was:

    1. nmake clean (I had to start with a clean build each time)

    2. remove the 'dll' fom the .pro

    3. nmake

    4. add the 'dll' back into the .pro

    5. nmake

    its worth a shot anyway ;-)



  • I am afraid that does not work. I am still getting moc errors, it appears that the command line for the moc command has some invalid paths in it, such as c:\program studio\vc98\include. Do you know how that command line is built?

    Thanks



  • I appear to have the build working now but when the DLL gets built it cannot be registered. Also running regsvr32 does not register the dll as loadlibrary fails!

    The output from the build from qt creator is as follows

    Running build steps for project simple...
    Configuration unchanged, skipping qmake step.
    Starting: "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" -w
    mingw32-make: Entering directory C:/qt/2010.04/qt/examples/activeqt/simple-build-desktop' C:/Qt/2010.04/mingw/bin/mingw32-make -f Makefile.Release all mingw32-make[1]: Entering directoryC:/qt/2010.04/qt/examples/activeqt/simple-build-desktop'
    C:\Qt\2010.04\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQAXSERVER -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\2010.04\qt\include\QtCore" -I"c:\Qt\2010.04\qt\include\QtGui" -I"c:\Qt\2010.04\qt\include" -I"c:\Qt\2010.04\qt\include\ActiveQt" -I"tmp\moc\release_shared" -I"..\simple" -I"c:\Program Files\Microsoft Visual Studio\VC98\include" -I"." -I"c:\Qt\2010.04\qt\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\simple\main.cpp -o tmp\moc\release_shared\main.moc
    g++ -c -O2 -w -frtti -fexceptions -mthreads -DUNICODE -DQT_LARGEFILE_SUPPORT -DQAXSERVER -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\2010.04\qt\include\QtCore" -I"c:\Qt\2010.04\qt\include\QtGui" -I"c:\Qt\2010.04\qt\include" -I"c:\Qt\2010.04\qt\include\ActiveQt" -I"tmp\moc\release_shared" -I"..\simple" -I"c:\Program Files\Microsoft Visual Studio\VC98\include" -I"." -I"c:\Qt\2010.04\qt\mkspecs\win32-g++" -o tmp\obj\release_shared\main.o ..\simple\main.cpp
    windres -i c:\Qt\2010.04\qt\src\activeqt\control\qaxserver.rc -o tmp\obj\release_shared\qaxserver_res.o --include-dir=c:/Qt/2010.04/qt/src/activeqt/control
    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -shared -mthreads -Wl -Wl,--out-implib,release\libsimpleax.a -Wl,C:/Qt/2010.04/qt/src/activeqt/control/qaxserver.def -o release\simpleax.dll tmp/obj/release_shared/main.o -L"c:\Qt\2010.04\qt\lib" -L"c:\Qt\2010.04\qt\lib" -lQAxServer tmp\obj\release_shared\qaxserver_res.o -luser32 -lole32 -loleaut32 -lgdi32 -luuid -lQtGui4 -lQtCore4
    Creating library file: release\libsimpleax.a
    c:\Qt\2010.04\qt\bin\idc.exe release\simpleax.dll /idl tmp\obj\release_shared/simpleax.idl -version 1.0
    midl tmp\obj\release_shared/simpleax.idl /nologo /tlb tmp\obj\release_shared/simpleax.tlb
    c:\Qt\2010.04\qt\bin\idc.exe release\simpleax.dll /tlb tmp\obj\release_shared/simpleax.tlb
    c:\Qt\2010.04\qt\bin\idc.exe release\simpleax.dll /regserver

    tmp\obj\release_shared\simpleax.idl

    process_begin: CreateProcess(NULL, midl tmp\obj\release_shared/simpleax.idl /nologo /tlb tmp\obj\release_shared/simpleax.tlb, ...) failed.
    make (e=2): The system cannot find the file specified.
    mingw32-make[1]: [release\simpleax.dll] Error 2 (ignored)
    Couldn't open tmp\obj\release_shared\simpleax.tlb for read
    mingw32-make[1]: [release\simpleax.dll] Error 4 (ignored)
    mingw32-make[1]: Leaving directory C:/qt/2010.04/qt/examples/activeqt/simple-build-desktop' C:/Qt/2010.04/mingw/bin/mingw32-make -f Makefile.Debug all Failed to register server! mingw32-make[1]: [release\simpleax.dll] Error 1 (ignored) mingw32-make[1]: Entering directoryC:/qt/2010.04/qt/examples/activeqt/simple-build-desktop'
    C:\Qt\2010.04\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQAXSERVER -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\2010.04\qt\include\QtCore" -I"c:\Qt\2010.04\qt\include\QtGui" -I"c:\Qt\2010.04\qt\include" -I"c:\Qt\2010.04\qt\include\ActiveQt" -I"tmp\moc\debug_shared" -I"..\simple" -I"c:\Program Files\Microsoft Visual Studio\VC98\include" -I"." -I"c:\Qt\2010.04\qt\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\simple\main.cpp -o tmp\moc\debug_shared\main.moc
    g++ -c -g -w -frtti -fexceptions -mthreads -DUNICODE -DQT_LARGEFILE_SUPPORT -DQAXSERVER -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\2010.04\qt\include\QtCore" -I"c:\Qt\2010.04\qt\include\QtGui" -I"c:\Qt\2010.04\qt\include" -I"c:\Qt\2010.04\qt\include\ActiveQt" -I"tmp\moc\debug_shared" -I"..\simple" -I"c:\Program Files\Microsoft Visual Studio\VC98\include" -I"." -I"c:\Qt\2010.04\qt\mkspecs\win32-g++" -o tmp\obj\debug_shared\main.o ..\simple\main.cpp
    windres -i c:\Qt\2010.04\qt\src\activeqt\control\qaxserver.rc -o tmp\obj\debug_shared\qaxserver_res.o --include-dir=c:/Qt/2010.04/qt/src/activeqt/control
    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -shared -mthreads -Wl -Wl,--out-implib,debug\libsimpleax.a -Wl,C:/Qt/2010.04/qt/src/activeqt/control/qaxserver.def -o debug\simpleax.dll tmp/obj/debug_shared/main.o -L"c:\Qt\2010.04\qt\lib" -L"c:\Qt\2010.04\qt\lib" -lQAxServerd tmp\obj\debug_shared\qaxserver_res.o -luser32 -lole32 -loleaut32 -lgdi32 -luuid -lQtGuid4 -lQtCored4
    Creating library file: debug\libsimpleax.a
    c:\Qt\2010.04\qt\bin\idc.exe debug\simpleax.dll /idl tmp\obj\debug_shared/simpleax.idl -version 1.0
    midl tmp\obj\debug_shared/simpleax.idl /nologo /tlb tmp\obj\debug_shared/simpleax.tlb
    c:\Qt\2010.04\qt\bin\idc.exe debug\simpleax.dll /tlb tmp\obj\debug_shared/simpleax.tlb
    c:\Qt\2010.04\qt\bin\idc.exe debug\simpleax.dll /regserver
    mingw32-make[1]: Leaving directory C:/qt/2010.04/qt/examples/activeqt/simple-build-desktop' mingw32-make: Leaving directoryC:/qt/2010.04/qt/examples/activeqt/simple-build-desktop'

    tmp\obj\debug_shared\simpleax.idl

    process_begin: CreateProcess(NULL, midl tmp\obj\debug_shared/simpleax.idl /nologo /tlb tmp\obj\debug_shared/simpleax.tlb, ...) failed.
    make (e=2): The system cannot find the file specified.
    mingw32-make[1]: [debug\simpleax.dll] Error 2 (ignored)
    Couldn't open tmp\obj\debug_shared\simpleax.tlb for read
    mingw32-make[1]: [debug\simpleax.dll] Error 4 (ignored)
    Failed to register server!
    mingw32-make[1]: [debug\simpleax.dll] Error 1 (ignored)
    The process "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" exited normally.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.