Results 1 to 6 of 6

Thread: mingw link with msvc dll

  1. #1
    Join Date
    Sep 2008
    Location
    Falmouth, MA, USA
    Posts
    34
    Thanks
    4
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default mingw link with msvc dll

    I know similar questions have been asked many times, and I have been through all of the answers I could find as best as I can...given that few of them are real specific. I have tried all of the suggestions I could find, to no avail. I am hoping that somebody will have something new to add given the specifics I describe.

    I am using a library made by Prosilica ( camera manufacturer--they have been acquired by Allied Vision, but it is still a "Prosilica" library). They provide a dll named PvAPI.dll, as well as a library called PvAPI.lib--apparently for Microsoft Visual Studio 6.0. These are described by Prosilica as "a standard call dll, which is accessible by most programming languages". Prosilica states that "Most compilers come with a tool to generate an import library from a DLL; see your compiler's manual for more information."

    I have successfully used this library with various versions of MS Visual Studio and QT for some time. Now, however, I am trying to transition away from MS development tools due to the difficulties in distribution of software when using MS tools. I am very happy with Creator/Mingw, with the sole exception (so far) that I have been unable to use the Prosilica dll.

    I have tried using pexports to produce a .def file, and dlltool to make a .a file--the result is undefined references to the Prosilica functions. I have tried using a .def file provided by Prosilica--same result


    I have tried using reimp to convert the .lib, and I get "invalid or corrupt import library" error messages.

    Is there something else to try? Prosilica has little to offer.

    Thanks in advance for any suggestions


    Jonathan Howland

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: mingw link with msvc dll

    If the Prosilica library is straight C-style interfaces (i.e. no name mangling) then you should be able to make this work. I gather that you have the necessary header files and that your code is compiling but failing to link. If the linker is not finding symbols check that you added the Prosilica library/library directory to the LIBS path.

    Otherwise this page described the need to post-process the pimport output for stdcall libraries.
    However, for __stdcall functions, the above method does not work. For MSVC will prefix an underscore to __stdcall functions while MinGW will not. The right way is to produce the DEF file using the pexports tool included in the mingw-utils package and filter off the first underscore by sed:

    pexports testdll.dll | sed "s/^_//" > testdll.def

    Then, when using dlltool to produce the import library, add `-U' to the command line:

    dlltool -U -d testdll.def -l libtestdll.a

    And now, you can proceed in the usual way:

    gcc -o testmain testmain.c -L. -ltestdll

  3. #3
    Join Date
    Dec 2011
    Location
    Jena, Germany
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: mingw link with msvc dll

    Hi, as a newbie I am not sure if I am really dealing with the same problem, but I assume it goes into the same direction:
    I am also trying to use an AVT library to access a "Pike" camera by Allied Vision. In VS2010 everything worked perfect, but I can't get it running in QT, even when I reduce the code to a minimal console application:

    .pro:
    Qt Code:
    1. QT += core
    2. QT -= gui
    3.  
    4. INCLUDEPATH += C:/FirePackage/FireGrab/Lib
    5. LIBS += C:/FirePackage/FireGrab/Lib/FGCamera.lib
    6. LIBS += C:/FirePackage/FireGrab/Lib/FGCamera.dll
    7.  
    8. TARGET = FirePackage_Console
    9. CONFIG += console
    10. CONFIG -= app_bundle
    11. TEMPLATE = app
    12. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 
    (please correct me if something is wrong)

    main.cpp:
    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <fgcamera.h>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QCoreApplication a(argc, argv);
    7. CFGCamera Camera;
    8. return a.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    In release mode, I get this:
    :: error: collect2: ld returned 1 exit status

    In debug mode the following:
    :: error: undefined reference to '_imp__ZN9CFGCameraD1Ev'
    :: error: undefined reference to '_imp__ZN9CFGCameraD1Ev'
    :: error: undefined reference to '_imp__ZN9CFGCameraD1Ev'
    :: error: collect2: ld returned 1 exit status

    When I comment out the CFGCamera instantiation it compiles.
    Are the library files somehow not compatible with QT? Is a "conversion" necessary/possible?? Can I do that as a non-programmer?

    Maybe you can tell more if you have a look at the library? You can find it here.
    Thanks for your help!

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: mingw link with msvc dll

    but I can't get it running in QT
    What does this mean? Qt isn't a compiler or linker. If you are no longer using MSVC, then the FGCamera.lib is probably not compatible with whatever compiler and linker you -are- using. I doubt it is necessary to add the .dll as one of the LIBS in the .pro file; it is run-time only, not used in compiling or linking.

    The previous answer by ChrisW is probably exactly what you need to do to make a compatible .lib from the DLL.

    When I comment out the CFGCamera instantiation it compiles.
    It already -is- compiling successfully with that instantiation in place. What it isn't doing is -linking- to produce an executable file. When you comment out that line, you are removing any references to the camera code from the link requirements, regardless of whether or not you include the header file for the CFGCamera class. Once you include the instantiation, you've created a link-time dependency for it.
    Last edited by d_stranz; 1st April 2012 at 20:52.

  5. #5
    Join Date
    Dec 2011
    Location
    Jena, Germany
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: mingw link with msvc dll

    Quote Originally Posted by d_stranz View Post
    What does this mean?
    ok, sorry, I am using qt creator and the mingw compiler.

    Quote Originally Posted by d_stranz View Post
    he previous answer by ChrisW is probably exactly what you need to do to make a compatible .lib from the DLL.
    could you give me a hint where to start? or even better, would someone be so kind and create a lib file from the dll for me? The link doesn't help that much...

  6. #6
    Join Date
    Dec 2011
    Location
    Jena, Germany
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: mingw link with msvc dll

    Sorry for bothering this part of the forum with newbie issues. Just wanted to tell that there seems to be a solution for my and maybe others' problems concerning this library:

    On AVT's homepage I found the following:
    The CFGCamera object of the MS VS C++ library FGCamera.lib could not be converted to MinGW compatible *.a library. That's why there's the C-wrapper FGWrap.dll providing the functions of the FireGrab interface to a camera handle instead of an CFGCamera object.
    See here for details.

    Thanks for your help.

Similar Threads

  1. Replies: 5
    Last Post: 20th September 2010, 11:30
  2. how to set QT Creator to use MSVC++ compiler instead of mingw
    By hcetiner in forum Installation and Deployment
    Replies: 5
    Last Post: 28th March 2010, 20:55
  3. Mingw vs MSVC?
    By vbman213 in forum Newbie
    Replies: 3
    Last Post: 18th February 2010, 08:51
  4. Open source dev on windows: MinGW vs MSVC
    By magland in forum Installation and Deployment
    Replies: 4
    Last Post: 29th December 2007, 09:20
  5. qmake for both msvc/mingw ?
    By gfunk in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2007, 13:06

Tags for this Thread

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.