g++ - Qt: mingw compiled library does only work with both library.so and library.lib file present -


i compiled library using mingw toolchain provided qt 5.0.2 on windows. result received library.so file. first failed using library in qt application, found out works fine when make copy of liblibrary.so file , call liblibrary.dll or liblibrary.lib (which file ending supported add library wizard in qtcreator).

now wonder if normal or if should change in order not have both files (which exact copies). leaving 1 away makes application crash during start up. added library follows qt pro file:

libs += -l"../path/to/library" -llibrary includepath += $$quote(../path/to/library) 

edit: compiled library using mingw of qt, not qt project using mingw32-make , provided makefile. result liblibrary.so.

edit: seems work when renaming copy liblibrary.dll instead of .lib. still, need 2 files make application work -- .so , .dll.

chris

that's weird, think should *.a , *.dll files when building shared lib mingw on windows, said in documentation:

in windows, mingw output .a , .dll, msvc2010 ouput .lib , .dll. in linux, mingw output .so, .so.1, .so.1.0 , .so.1.0.0 – .lib, .a , .so import libraries.

you shouldn't rename file!

be careful to:

  • not include "lib" prefix after "-l" in project file.
  • put after after "-l" in lower case you're on windows
  • not adding extension library name after "-l"
  • add , reference .h file used in library

a real example using qtwebsocket lib:

includepath += "$${pwd}/include/"  libs += -l"$${pwd}/libs/" -lqtwebsocket ... headers += ... \        $${pwd}/include/qwssocket.h \        ... 

in include/ folder, have following file:

  • qwssocket.h (taken original project - required)

in libs/ folder, have following file:

  • libqtwebsocket.a
  • qtwebsocket.dll

edit: struggled initially. have tried build lib static lib instead (config += staticlib in library project)? might getting *.pro file right before switching using shared library.

edit 2: ok, fact *.so file still bit odd. in this question user has same issue , keep both files, workaround. according a later answer seems need modify makefile generate file proper extension. maybe help: http://www.mingw.org/wiki/sampledll


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -