0

I'm working with QtCreator under MacOS to target iPhone for my applications. Right now, I'm trying got compile a 3rd party library (tinyxml).

My .pro file already works for Linux, Windows and Android targets, I'm just trying to extend it to iOS.

My first surprise is that the generated dynamic library has a .a extension. Shouldn't it be .so (or even `.dynlib)?

My second surprise is that when I generate the library with and without CONFIG += staticlib, it always produces the same binary (actually, the same size, content is reported as being different, but it may only be the SONAME tag). On every other platform, static and dynamic library binaries always have a different size.

Am I doing something wrong? Am I actually always generating the library statically (that would explain the extension being always .a), and if so, how to force the dynamic generation?

Dynamic .pro file:

#Generated by SDE CMake scripts!
CONFIG(release, debug|release) {
TARGET = tinyxml
}

CONFIG(debug, debug|release) {
TARGET = tinyxml-g
}

QT -= core

QT -= gui

CONFIG(debug, debug|release) {
DEFINES += _DEBUG
}

win32: DEFINES += TINYXML_EXPORTS

SOURCES +=  \ 
/Users/less/Documents/dev/vobs_ext/libcpp/tinyxml/src/tinystr.cpp \ 
/Users/less/Documents/dev/vobs_ext/libcpp/tinyxml/src/tinyxml.cpp \ 
/Users/less/Documents/dev/vobs_ext/libcpp/tinyxml/src/tinyxmlerror.cpp \ 
/Users/less/Documents/dev/vobs_ext/libcpp/tinyxml/src/tinyxmlparser.cpp

TEMPLATE = lib

INCLUDEPATH +=  \ 
/Users/less/Documents/dev/vobs_ext/libcpp/tinyxml/./tinyxml

Static .pro file:

#Generated by SDE CMake scripts!
CONFIG(release, debug|release) {
TARGET = tinyxmls
}

CONFIG(debug, debug|release) {
TARGET = tinyxmls-g
}

QT -= core

QT -= gui

CONFIG(debug, debug|release) {
DEFINES += _DEBUG
}

win32: DEFINES += TINYXML_EXPORTS

QMAKE_CXXFLAGS += -DTINYXML_STATIC

SOURCES +=  \ 
/Users/less/Documents/dev/vobs_ext/libcpp/tinyxml/src/tinystr.cpp \ 
/Users/less/Documents/dev/vobs_ext/libcpp/tinyxml/src/tinyxml.cpp \ 
/Users/less/Documents/dev/vobs_ext/libcpp/tinyxml/src/tinyxmlerror.cpp \ 
/Users/less/Documents/dev/vobs_ext/libcpp/tinyxml/src/tinyxmlparser.cpp

TEMPLATE = lib

CONFIG += staticlib

INCLUDEPATH +=  \ 
/Users/less/Documents/dev/vobs_ext/libcpp/tinyxml/./tinyxml
jpo38
  • 20,821
  • 10
  • 70
  • 151

1 Answers1

0

Got it.

For windows and Android target, default library building is dynamic, so I never had to put anything else than TEMPLATE += lib. On Mac, it's static by default. So, to generate a dynamic library (.dylib), you must request it by adding CONFIG += shared.

This compiles, but crashs upon deployment. I posted this on a different thread: QtCreator for iOS: How to deploy a dylib shared library with my application

Community
  • 1
  • 1
jpo38
  • 20,821
  • 10
  • 70
  • 151