Results 1 to 3 of 3

Thread: Qt + Portmidi in Windows... libraries problem

  1. #1
    Join Date
    Apr 2007
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt + Portmidi in Windows... libraries problem

    Hi:

    Qt 4 Open Source.

    I've got Qt and Portmidi working under Linux.

    Now, both things are cross-platform, so I'm trying to run the same program that runs in Linux, in Windows XP.


    Portmidi libraries are prepared for Visual Studio. I create them: two .lib and one .dll using Visual Studio.

    Qt Open Source for Windows uses mingw make.

    The problem... I add the libraries in the project .pro file, but when I compile I get many undefined stuff, like this...

    C:/portmidi/pm_win/Debug/portmidi.lib(./pm_win/Debug/portmidi.obj)(.text[_pm_add_device]+0x166): undefined reference to `_RTC_CheckEsp'
    C:/portmidi/pm_win/Debug/portmidi.lib(./pm_win/Debug/portmidi.obj)(.rtc$TMZ+0x0): undefined reference to `_RTC_Shutdown'
    C:/portmidi/pm_win/Debug/portmidi.lib(./pm_win/Debug/portmidi.obj)(.rtc$IMZ+0x0): undefined reference to `_RTC_InitBase'
    C:/portmidi/pm_win/Debug/portmidi.lib(./pm_win/Debug/portmidi.obj)(.text[_Pm_CountDevices]+0x34): undefined reference to `_RTC_CheckEsp'
    C:/portmidi/pm_win/Debug/portmidi.lib(./pm_win/Debug/portmidi.obj)(.text[_Pm_GetDeviceInfo]+0x50): undefined reference to `_RTC_CheckEsp'
    C:/portmidi/pm_win/Debug/portmidi.lib(./pm_win/Debug/portmidi.obj)(.text[_none_get_host_error]+0x3b): undefined reference to `_RTC_CheckEsp'
    C:/portmidi/pm_win/Debug/portmidi.lib(./pm_win/Debug/portmidi.obj)(.text[_Pm_GetHostErrorText]+0x38): undefined reference to `_wassert'
    C:/portmidi/pm_win/Debug/portmidi.lib(./pm_win/Debug/portmidi.obj)(.text[_Pm_GetHostErrorText]+0x59): undefined reference to `_wassert'
    C:/portmidi/pm_win/Debug/portmidi.lib(./pm_win/Debug/portmidi.obj)(.text[_Pm_GetHostErrorText]+0xad): undefined reference to `_RTC_CheckEsp'


    Do I need to compile portmidi with mingw or is it just a problem in my .pro?

    # File generated by kdevelop's qmake manager.
    # -------------------------------------------
    # Subdir relative project main directory: .
    # Target is an application: Control

    INCLUDEPATH += . C:/portmidi/pm_common C:/portmidi/porttime C:/portmidi/pm_win
    LIBS += C:/portmidi/pm_win/Debug/portmidi.lib
    LIBS += C:/portmidi/porttime/Debug/porttime.lib

    include(manager.pro)
    TARGET = Control
    (I'm using 2 .pro... but this is the one with the interesting stuff for this example...)


    Any ideas? :-)

    Thanks!

    Regards
    Hipo

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt + Portmidi in Windows... libraries problem

    Looks like a linker error... Maybe your Portmidi library brings some extra dependencies which are not notified to the linker by default (which you should thus add by hand in the pro file).
    Current Qt projects : QCodeEdit, RotiDeCode

  3. #3
    Join Date
    Jun 2009
    Posts
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Qt + Portmidi in Windows... libraries problem

    I'd encountered recently a similar problem. Here are the explanation of
    its root and the recipe of the workaround. May be it would be useful to somebody.

    The debug version of the external MyLibrary.lib has been compiled by means of
    Visual Studio .NET 2003. When it is linked with the Qt project unresolved
    references to _RTC_CheckEsp etc. stuff appeared. These functions implement
    Runtime Checks and were introduced by Microsoft into C Runtime Library
    (i.e. CRT) beginning from Visual Studio .NET.

    MinGW uses earlier version of CRT - Visual Studio 6.0 to be precise -
    (implemented by MSVCRT.DLL) so there is nothing astonishing in unresolved
    references.

    I had attempted to uncheck the C/C++/Code Generation/Basic Runtime checks in
    MyLibrary Visual Studio project but references to _RTC_Initialize and _RTC_Terminate
    persisted as unresolved. I had attempted also to link additionally static
    library LIBCMTD.LIB. Unresolved references have gone but as one may expect
    duplicated name mainCRTStartup appeared.

    Then I had found out that RunTmChk.lib allows to implement Runtime Checks
    without C Runtime Library - see http://msdn.microsoft.com/en-us/library/azff25ez.aspx.
    (In my case MinGW uses C Runtime Library but for my goals I may successfully
    imagine that no C Runtime Library presents.)
    One needs to include RunTmChk.lib into .pro-file and implement _CRT_RTC_INIT function
    in one's Qt code. _CRT_RTC_INIT should install error reporting function.
    As explained in comments within file RTCAPI.H error reporting function may be NULL.

    RECIPE. So workaround is:

    1. Add to .pro-file lines:

    MSVC2003_LIBPATH = "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\"
    win32 {
    if (DebugBuild) {
    LIBS += -LD:\Projects\MyLibrary\Debug\ -lMyLibrary
    LIBS += -L$$MSVC2003_LIBPATH -lRunTmChk
    }
    if (ReleaseBuild) {
    LIBS += -LD:\Projects\MyLibrary\Release\ -lMyLibrary }
    }

    2. Add to the Qt project new .cpp-file containing lines:

    extern "C" {
    #define NULL 0
    typedef int (__cdecl *_RTC_error_fn)(int, const char *, int, const char *, const char *, ...);
    _RTC_error_fn _CRT_RTC_INIT(void *res0, void **res1, int res2, int res3, int res4);
    }
    _RTC_error_fn _CRT_RTC_INIT(void *res0, void **res1, int res2, int res3, int res4)
    {
    return NULL;
    }

    Now all the problems caused by the RTC would go. Of course, this approach cannot help
    with other Runtime Library extras like _wassert.

    Regards
    Yuri Osipov

Similar Threads

  1. Thread problem with windows
    By vratojr in forum Qt Programming
    Replies: 17
    Last Post: 16th June 2006, 08:34
  2. problem of porting from windows to linux
    By jyoti kumar in forum Qt Programming
    Replies: 4
    Last Post: 22nd May 2006, 08:42
  3. Replies: 10
    Last Post: 28th April 2006, 15:48
  4. Problem building Qt4.1.0 with thread support on windows XP
    By pavithra in forum Installation and Deployment
    Replies: 1
    Last Post: 1st April 2006, 11:35
  5. QProcess problem with windows batch file
    By bood in forum Qt Programming
    Replies: 11
    Last Post: 6th January 2006, 08:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.