[Solved] Problem with dll files during compiling



  • Hello, I can't compile an easy code with Visual basic 2012 and qt for 32 bits. Some error messages with dll come to stop the process. I have already tried to add QT += core gui, QT += widgets, QT += sql and DEFINES += QT_NODLL in my .pro file, but it didn't change anything.

    My libpath is: D:\Qt\5.2.1\msvc2012\lib\cmake\Qt5Gui;D:\Qt\5.2.1\msvc2012\lib\cmake\Qt5Sql;D:\Qt\5.2.1\msvc2012\lib\cmake;D:\Qt\5.2.1\msvc2012\lib\cmake\Qt5Declarative;D:\Qt\5.2.1\msvc2012\lib\cmake\Qt5Designer;D:\Qt\5.2.1\msvc2012\lib\cmake\Qt5Test;D:\Qt\5.2.1\msvc2012\lib\cmake\Qt5;D:\Qt\5.2.1\msvc2012\lib\cmake\Qt5Widgets;D:\Qt\5.2.1\msvc2012\lib\cmake\Qt5Core;D:\Qt\5.2.1\msvc2012\bin;D:\Qt\5.2.1\msvc2012\lib;$(LibraryPath)

    The output message is:

    @cl -c -nologo -Zm200 -Zc:wchar_t -Zi -MDd -GR -W3 -w34100 -w34189 -EHsc /Fddebug\Project1.pdb -DUNICODE -DWIN32 -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"." -I"D:\Qt\5.2.1\msvc2012\include" -I"D:\Qt\5.2.1\msvc2012\include\QtGui" -I"D:\Qt\5.2.1\msvc2012\include\QtANGLE" -I"D:\Qt\5.2.1\msvc2012\include\QtCore" -I"debug" -I"D:\Qt\5.2.1\msvc2012\mkspecs\win32-msvc2012" -Fodebug\ @D:\Users\fpellecc\AppData\Local\Temp\nm29B0.tmp
    1> main.cpp
    1> echo 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID / 24 / RT_MANIFEST / "debug\Project1.exe.embed.manifest">debug\Project1.exe_manifest.rc
    1> if not exist debug\Project1.exe if exist debug\Project1.exe.embed.manifest del debug\Project1.exe.embed.manifest
    1> if exist debug\Project1.exe.embed.manifest copy /Y debug\Project1.exe.embed.manifest debug\Project1.exe_manifest.bak
    1> link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='
    ' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:debug\Project1.exe.embed.manifest /OUT:debug\Project1.exe @D:\Users\fpellecc\AppData\Local\Temp\nm5755.tmp
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QApplication::QApplication(int &,char * *,int)" (_imp??0QApplication@@QAE@AAHPAPADH@Z) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QApplication::~QApplication(void)" (_imp??1QApplication@@UAE@XZ) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" (_imp?exec@QApplication@@SAHXZ) referenced in function _main
    1>debug\Project1.exe : fatal error LNK1120: 3 unresolved externals
    1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\link.EXE"' : return code '0x460'
    1> Stop.
    1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\nmake.exe"' : return code '0x2'
    1> Stop.
    1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(43,5): error MSB3073: The command "qmake && nmake debug-clean debug" exited with code 2.
    ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
    @

    The code is:

    @#include <QApplication>
    #include <QtWidgets>

    int main (int argc, char *argv[])
    {
    QApplication app(argc, argv);
    // QPushButton bouton("Coucou!");
    // bouton.show();

    return app.exec();
    }@

    Would anyone have a solution about this problem?



  • Hi, if you only want to try such a simple program as your main.cpp, then you shouldn't have to change anything in your .pro file.

    Maybe, test that your QtCreator etc. works ok, make another simple program, for example do New Project, select a Qt Widgets application. Don't edit it, just try to build it and see if it runs ok.



  • I tried to compile a new Qt widget application in QtCreator, but it didn't work because of the include path:

    @D:\Qt\5.2.1\msvc2012\include\QtCore\qglobal.h:46: error: C1083: Cannot open include file: 'stddef.h': No such file or directory@

    I tried to add this line in the .pro file, but still no changes:

    @INCLUDEPATH += "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include"@

    The stddef.h is in this include folder



  • I assume that you use QtCreator.
    Have you checked that compiler, qt versions, and qt kits are correctly recognized by QtCreator.
    Take a look at Options/Build & Run and see if there are any errors, warnings in the "Compilers", "Qt Versions", "Kits" tabs.



  • Thank you for your reply!

    There is only a warning for kits. It says
    @Desktop Qt 5.2.1 MSVC2012 32bit (default)@

    For the compiler there is no error, there are four lines:

    @Microsoft Visual C++ Compiler 11.0 (x86) MSVC
    Microsoft Visual C++ Compiler 11.0 (amd64) MSVC
    Microsoft Visual C++ Compiler 11.0 (arm) MSVC
    MinGW (x86 32bit in C:\Programs\MinGW32-xy\bin) MinGW@



  • Maybe Qt's initialization for MSVC2012 is broken: check in the Options, Build & Run, Compilers tab, in the list of your 4 compilers, click in the first (1. in your list above).
    Check "Initialization:" below, it should say "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat x86"

    This is the .bat file that QtCreator runs to set the include path to stddef.h (among other things).

    If you have that line ok, start a cmd window, and see what happens if you start it by hand. It should call the vcvars32.bat file in the bin directory below.



  • The initialization is ok for the first line.

    I'm sorry, I'm a beginner: how could I start a command prompt window and start it by hand?

    I don't know if it's right, but I've read that I should compile my program with MinGW instead of MSVC2012.. But I've just one choice for "Debug", MinGW doesn't appear



  • If you click on "Desktop Qt 5.2.1 MSVC2012 32bit (default)"
    then what "Compiler" and "Qt version" are selected in the fields below ?

    To start a cmd shell press "Windows Logo+R", type cmd.exe in the dialog that will appear and press Enter.



  • Hmm, I think getting MinGW to work could be easier than Visual Studio.
    Perhaps you try uninstalling Qt, and installing it again choosing only the MingGW 4.8 compiler.



  • I agree with hskoglund that it is easier to deal with the only one Qt kit.



  • I tried to uninstall and install again QtCreator, but I had no choice for the compiler type. The problem is that I have to program with Visual Studio 2012, then I must install the version qt-opensource-windows-x86-msvc2012-5.2.1.exe.
    But with this version, both msvc and MinGW compiler are installed, and I still can't choose MinGW..

    Can I install the version Qt 5.2.1 for Windows 32-bit (MinGW 4.8, OpenGL, 634 MB) and use Qt in my Visual Basic 2012 program?



  • Sorry I didn't see before you want to use Qt in Visual Basic, that's a bit complicated!
    You mean you want to call Qt functions from a Visual Basic program or the other way around, i.e. using Visual Basic functions from a Qt program?



  • I would like to call qt functions from Visual Basic 2012.
    But I need Qt Creator to create my graphic interface with qt designer too



  • I see!
    Ok back to your problem: not being able to select MinGW, I don't really see why? Anyway, I think perhaps to simplify, try uninstalling, but this time uninstall both Qt and Visual Studio 2012.

    Now when you have your Windows PC without any development tools installed, then install first Qt with MinGW.
    After you've verified that you can compile and run a Qt program (with MinGW selected) you then proceed to install Visual Studio 2012 to get Visual Basic 2012 up and running again :-)



  • I've just installed the Qt version with MinGW and QtCreator works! Thank you for the idea

    Now I have two version, one to use QtCreator, and one to be used in Visual Basic. I tried to launch a small qt program in Visual Basic 2012: there are no erros, but the application can't be opened after the compilation.. It says:

    @Unable to start program 'h:\Visual Studio 2012\Projects\Project1\Project1.exe'. The system cannot find the file specified@


Log in to reply
 

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