Results 1 to 6 of 6

Thread: adding external .lib

  1. #1
    Join Date
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default adding external .lib

    hello!

    i'm just a noob in Qt programing and i can't figure this out:

    i'm using Qt 4.4.3 integrated with Wascana version of Eclipse CDT under vista. i'm trying to add an external .lib to my project for handling a parallel port (inpout32). I edited my .pro like so:

    TEMPLATE = app
    TARGET = testLPT
    QT += core gui
    HEADERS += testlpt.h

    LIBS += C:/libraries/inpout32.lib
    INCLUDEPATH = C:/libraries

    SOURCES = main.cpp \
    testlpt.cpp

    FORMS += testlpt.ui


    when i try to compile the whole thing i get this:

    debug/testlpt.o(.text+0x77a): In function `ZN7testLPT8OnOffLPTEv':
    C:/Naukowe Bzdety/Wascana Workspaces/Workspace/testLPT/testlpt.cpp:32: undefined reference to `_Z18IsInpOutDriverOpenv@0'
    collect2: ld returned 1 exit status
    mingw32-make[1]: *** [debug\testLPT.exe] Error 1
    mingw32-make[1]: Leaving directory `C:/Naukowe Bzdety/Wascana Workspaces/Workspace/testLPT'
    mingw32-make: *** [debug] Error 2

    can anyone please tell me what is the problem here??

  2. #2
    Join Date
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding external .lib

    i should probably add that "IsInpOutDriverOpen();" is the only function from the library i want to add and testLPT::OnOff(); is the function that calls it

  3. #3
    Join Date
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding external .lib

    well, i know now that this has nothing to do with the .h file. it looks like the .lib is not being linked with my project. it seems that lots of people have the same problem. could anyone please post some hints or direct me to some usefull info?

  4. #4
    Join Date
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding external .lib

    Qt's .lib managment is starting to piss me off.. scaning Qt forums i found lots of threads describing the same problem: linking third party libraries to peoples Qt projects (none were resolved). HAS ANYONE EVER DONE THAT SUCCESFULLY IN HIS PROJECT ?????????????!!!!!!!!!!!!!!!

  5. #5
    Join Date
    Apr 2010
    Posts
    27
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: adding external .lib

    I know this thread has been down for a couple of years, but I am having the same problem. Don't suppose you found a solution did you Sqvarek?

  6. #6
    Join Date
    Apr 2010
    Posts
    27
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: adding external .lib

    Ok, so I've not actually gone ahead and tried this solution, but I am sure the problem lies in the compatibilty between MSVC and Ming according to this:

    http://outofhanwell.wordpress.com/20...ingw-projects/

    MSVC and MinGW, we discovered, use different naming conventions for stdcall functions. MSVC exports them as _name@ordinal, but MinGW exports them as name. As a result, the MinGW build failed with “undefined references” link errors when calling stdcall functions exported from the MSVC library.

    The MinGW FAQ discusses this problem and offers a solution:

    1. Create a definition file using reimp (for lib files) or pexports (for dll files).
    2. Remove the underscore prefixes from the stdcall functions.
    3. Use dlltool to convert the MSVC library into a MinGW library with the new definition.


    That didn’t work. We finally removed the ordinals from the function names, which caused it to compile. But the program wouldn’t run because it couldn’t find the linked functions in the DLL. Finally, after consulting the MSDN documentation for definition files, we changed the build instructions:

    1. Create a definition file using reimp.
    2. For each stdcall function (formatted as _name@ordinal) add a line name = _name@ordinal, allowing MinGW to map its stdcall naming convention to that of MSVC.
    3. Use dlltool to convert the MSVC library into a MinGW library with the new definition.


    It worked! To compile the project you must simply:

    1. Download and install the Qt/Windows package, which includes MinGW.
    2. Download reimp and drop it into the MinGW/bin folder.
    3. Download the development packages for the third-party libraries and point an environment variable to that location.
    4. Build the project with the usual qmake/make commands.
    I might try and recompile the source code of the libraries with Ming as I have access to it.

    I hope this helps someone.

Similar Threads

  1. Q3ScrollView resists to scroll down to the garbage bin
    By sivrisinek in forum Qt Programming
    Replies: 0
    Last Post: 5th February 2009, 17:50
  2. Adding an external Library
    By afflictedd2 in forum Qt Programming
    Replies: 1
    Last Post: 13th December 2008, 05:51
  3. shared vs static
    By alisami in forum Installation and Deployment
    Replies: 3
    Last Post: 4th October 2008, 13:04
  4. Replies: 16
    Last Post: 23rd May 2008, 10:12
  5. Link Errors
    By magikalpnoi in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 22:04

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.