1
votes

I'm trying to include one internal library to my application, but I'm getting following linking error. The libraries are found. The library is compiled with exactly the same flags as the application. This works fine on windows, but gives troubles in osx. For me it looks like it can not find stl library?

I have also added following flags to qmake, but no help:

CONFIG += c++11
LIBS += -stdlib=libc++

QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11

error message:

Target: x86_64-apple-darwin14.4.0 Thread model: posix "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -headerpad_max_install_names -macosx_version_min 10.7.0 -o CryptoTest.app/Contents/MacOS/CryptoTest -lcrt1.10.6.o -L/Users/eDS/dev/ed/CryptoTest -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -rpath /Users/eDS/Qt/5.4/clang_64/lib obj/main.o obj/mainwindow.o obj/moc_mainwindow.o -lc++ -lcryptopp -llicensing -framework QtSvg -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework QtQuickWidgets -framework QtQuick -framework QtQml -framework QtNetwork -framework QtPrintSupport -framework QtWebKitWidgets -framework QtWebKit -framework Qt3D -framework QtOpenGL -framework QtXml -framework QtSql -framework OpenGL -framework AGL -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/lib/darwin/libclang_rt.osx.a -F/Users/eDS/Qt/5.4/clang_64/lib
Undefined symbols for architecture x86_64:
"std::istream::gcount() const", referenced from:

CryptoPP::operator>>(std::istream&, CryptoPP::Integer&) in libcryptopp.a(integer.o) "std::string::data() const", referenced from: Licensing::RsaVerifySignature(std::string, std::string) in liblicensing.a(licensing.o)

2

2 Answers

1
votes

It seems that clang still has some problems with C++11, see this thread, it is old but I think still actual:

https://forum.qt.io/topic/23989/solved-make-qtcreator-qmake-and-clang3-2-work-with-c-11/27

You should use something like that in pro file:

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

LIBS += -stdlib=libc++

QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -mmacosx-version-min=10.7
QMAKE_LFLAGS += -mmacosx-version-min=10.7

It will be a workaround for clang.

1
votes

it turned out that the library was not compiled with c+11 flags. After adding following everything worked fine

LIBS += -stdlib=libc++
CONFIG += c++11
QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11