Skip to content

Commit

Permalink
fix static link on windows
Browse files Browse the repository at this point in the history
dllimport must be removed if link to a static lib. now it's not removed
because it's impossible to detect whether we link to a static lib
  • Loading branch information
wang-bin committed Apr 23, 2015
1 parent a4b6b46 commit 9e092b0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 5 deletions.
5 changes: 4 additions & 1 deletion common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ defineReplace(qtLibName) {

#fakelib
defineReplace(qtStaticLib) {
# static lib does not have major version flag at the end
unset(LIB_FULLNAME)
LIB_FULLNAME = $$qtLibName($$1, $$2)
TEMPLATE += fakelib
LIB_FULLNAME = $$qtLibraryTarget($$1)
TEMPLATE -= fakelib
LIB_FULLNAME = $${QMAKE_PREFIX_STATICLIB}$$member(LIB_FULLNAME, 0).$${QMAKE_EXTENSION_STATICLIB}
return($$LIB_FULLNAME)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/common/common.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TEMPLATE = lib
DEFINES += BUILD_QOPT_LIB

CONFIG *= common-buildlib staticlib

staticlib: DEFINES += BUILD_COMMON_STATIC
#var with '_' can not pass to pri?
PROJECTROOT = $$PWD/../..
!include(libcommon.pri): error("could not find libcommon.pri")
Expand Down
8 changes: 5 additions & 3 deletions examples/common/common_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

#include <QtCore/qglobal.h>


#ifdef BUILD_COMMON_STATIC
#define COMMON_EXPORT
#else
#if defined(BUILD_COMMON_LIB)
# undef COMMON_EXPORT
# define COMMON_EXPORT Q_DECL_EXPORT
#else
# undef COMMON_EXPORT
# define COMMON_EXPORT Q_DECL_IMPORT //only for vc?
# define COMMON_EXPORT //Q_DECL_IMPORT //only for vc? link to static lib error
#endif

#endif //BUILD_COMMON_STATIC
#endif // COMMON_EXPORT_H
4 changes: 4 additions & 0 deletions src/QtAV/QtAV_Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@
#include <QtCore/qglobal.h>
#include "dptr.h"

#ifdef BUILD_QTAV_STATIC
#define Q_AV_EXPORT
#else
#if defined(BUILD_QTAV_LIB)
# undef Q_AV_EXPORT
# define Q_AV_EXPORT Q_DECL_EXPORT
#else
# undef Q_AV_EXPORT
# define Q_AV_EXPORT Q_DECL_IMPORT //only for vc?
#endif
#endif //BUILD_QTAV_STATIC
#define Q_AV_PRIVATE_EXPORT Q_AV_EXPORT

/* runtime version. used to compare with compile time version */
Expand Down
1 change: 1 addition & 0 deletions src/libQtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ greaterThan(QT_MAJOR_VERSION, 4) {
config_gl: QT += opengl
}
CONFIG *= qtav-buildlib
staticlib: DEFINES += BUILD_QTAV_STATIC
INCLUDEPATH += $$[QT_INSTALL_HEADERS]

#mac: simd.prf will load qt_build_config and the result is soname will prefixed with QT_INSTALL_LIBS and link flag will append soname after QMAKE_LFLAGS_SONAME
Expand Down
5 changes: 5 additions & 0 deletions widgets/QtAVWidgets/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@

#include <QtAV/VideoRendererTypes.h>


#ifdef BUILD_QTAVWIDGETS_STATIC
#define Q_AVWIDGETS_EXPORT
#else
#if defined(BUILD_QTAVWIDGETS_LIB)
# undef Q_AVWIDGETS_EXPORT
# define Q_AVWIDGETS_EXPORT Q_DECL_EXPORT
#else
# undef Q_AVWIDGETS_EXPORT
# define Q_AVWIDGETS_EXPORT Q_DECL_IMPORT //only for vc?
#endif
#endif //BUILD_QTAVWIDGETS_STATIC
#define Q_AVWIDGETS_PRIVATE_EXPORT Q_AVWIDGETS_EXPORT

namespace QtAV {
Expand Down
3 changes: 3 additions & 0 deletions widgets/libQtAVWidgets.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ greaterThan(QT_MAJOR_VERSION, 4) {
}
}
CONFIG *= qtavwidgets-buildlib
staticlib: DEFINES += BUILD_QTAVWIDGETS_STATIC

INCLUDEPATH += $$[QT_INSTALL_HEADERS]
#release: DEFINES += QT_NO_DEBUG_OUTPUT
#var with '_' can not pass to pri?
Expand Down Expand Up @@ -94,6 +96,7 @@ config_gdiplus {
SOURCES += $$QTAVSRC/output/video/GDIRenderer.cpp
LIBS += -lgdiplus -lgdi32
}

config_direct2d {
DEFINES *= QTAV_HAVE_DIRECT2D=1
!*msvc*: INCLUDEPATH += $$PROJECTROOT/contrib/d2d1headers
Expand Down

0 comments on commit 9e092b0

Please sign in to comment.