体系结构的未定义符号 x86_64:"hex(QTextStream&)",引用自:(在 Mac 上安装 PyQwt-5.2.0)

Undefined symbols for architecture x86_64: "hex(QTextStream&)", referenced from: (Installing PyQwt-5.2.0 on Mac)

我正在尝试安装用于 LC/MS 分析的 emzed python 包。这个包依赖于 PyQt4 和 PyQWT。我已经安装了所有东西,但无法构建 PyQWT。我已经跳过了很多错误,并且在这个链接错误上卡住了一段时间。

我已经尝试修改 makefile (Qwt_version_info.mak) 以将包含目录传递给它。我不知道如何指定合适的链接库来编译(QTextStream 等)

$  make -f qwt_version_info.mak 
Are we linking yet?1
Are we linking yet?2
Are we linking yet?3
Are we linking yet?4
Are we linking yet?5
g++ -v -headerpad_max_install_names -o qwt_version_info.app/Contents/MacOS/qwt_version_info qwt_version_info.o      
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
 "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -headerpad_max_install_names -macosx_version_min 10.9.0 -o qwt_version_info.app/Contents/MacOS/qwt_version_info qwt_version_info.o -lc++ -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "hex(QTextStream&)", referenced from:
      _main in qwt_version_info.o
  "QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)", referenced from:
      QTypedArrayData<unsigned short>::deallocate(QArrayData*) in qwt_version_info.o
  "QTextStream::QTextStream(QIODevice*)", referenced from:
      _main in qwt_version_info.o
  "QTextStream::~QTextStream()", referenced from:
      _main in qwt_version_info.o
  "QTextStream::operator<<(char const*)", referenced from:
      _main in qwt_version_info.o
  "QTextStream::operator<<(int)", referenced from:
      _main in qwt_version_info.o
  "QFile::open(QFlags<QIODevice::OpenModeFlag>)", referenced from:
      _main in qwt_version_info.o
  "QFile::QFile(QString const&)", referenced from:
      _main in qwt_version_info.o
  "QFile::~QFile()", referenced from:
      _main in qwt_version_info.o
  "QString::fromAscii_helper(char const*, int)", referenced from:
      QString::QString(char const*) in qwt_version_info.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [qwt_version_info.app/Contents/MacOS/qwt_version_info] Error 1

这是生成文件。

1591 $  cat qwt_version_info.mak 
#############################################################################
# Makefile for building: qwt_version_info.app/Contents/MacOS/qwt_version_info
# Generated by qmake (2.01a) (Qt 4.8.7) on: Tue Aug 13 11:31:21 2019
# Project:  qwt_version_info.pro
# Template: app
# Command: /usr/local/opt/qt@4/bin/qmake -spec /usr/local/etc/qt4/mkspecs/macx-g++ -o qwt_version_info.mak qwt_version_info.pro
#############################################################################

####### Compiler, tools and options

CC            = gcc
CXX           = g++
DEFINES       = 
CFLAGS        = -pipe $(DEFINES)
CXXFLAGS      = -pipe -std=c++11 $(DEFINES)
INCPATH       = -I/usr/local/etc/qt4/mkspecs/macx-g++ -I. -I../qwt-5.2/src -I/usr/local/Cellar/qt@4/4.8.7_5/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/sip/4.19.8_12/include -I/Users/Danny/.virtualenvs/emzed2.7/lib/python2.7/site-packages/numpy/core/include
LINK          = g++
LFLAGS        = -headerpad_max_install_names
LIBS          = $(SUBLIBS)    
AR            = ar cq
RANLIB        = ranlib -s
QMAKE         = /usr/local/opt/qt@4/bin/qmake
TAR           = tar -cf
COMPRESS      = gzip -9f
COPY          = cp -f
SED           = sed
COPY_FILE     = cp -f
COPY_DIR      = cp -f -R
STRIP         = 
INSTALL_FILE  = $(COPY_FILE)
INSTALL_DIR   = $(COPY_DIR)
INSTALL_PROGRAM = $(COPY_FILE)
DEL_FILE      = rm -f
SYMLINK       = ln -f -s
DEL_DIR       = rmdir
MOVE          = mv -f
CHK_DIR_EXISTS= test -d
MKDIR         = mkdir -p
export MACOSX_DEPLOYMENT_TARGET = 10.9

####### Output directory

OBJECTS_DIR   = ./

####### Files

SOURCES       = qwt_version_info.cpp 
OBJECTS       = qwt_version_info.o
DIST          = /usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/unix.conf \
        /usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/mac.conf \
        /usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/gcc-base.conf \
        /usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/gcc-base-macx.conf \
        /usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/g++-base.conf \
        /usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/g++-macx.conf \
        qwt_version_info.pro
QMAKE_TARGET  = qwt_version_info
DESTDIR       = 
TARGET        = qwt_version_info.app/Contents/MacOS/qwt_version_info

first: all
####### Implicit rules

.SUFFIXES: .o .c .cpp .cc .cxx .C

.cpp.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cc.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cxx.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.C.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.c.o:
    $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"

####### Build rules

all: qwt_version_info.mak qwt_version_info.app/Contents/PkgInfo qwt_version_info.app/Contents/Resources/empty.lproj $(TARGET)

$(TARGET):  $(OBJECTS)  
    @$(CHK_DIR_EXISTS) qwt_version_info.app/Contents/MacOS/ || $(MKDIR) qwt_version_info.app/Contents/MacOS/ 
    $(LINK) -v $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

$(info Are we linking yet?1)

qwt_version_info.mak: qwt_version_info.pro  /usr/local/etc/qt4/mkspecs/macx-g++/qmake.conf /usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/unix.conf \
        /usr/local/etc/qt4/mkspecs/common/mac.conf \
        /usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/gcc-base.conf \
        /usr/local/etc/qt4/mkspecs/common/gcc-base-macx.conf \
        /usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/g++-base.conf \
        /usr/local/etc/qt4/mkspecs/common/g++-macx.conf
    $(QMAKE) -spec /usr/local/etc/qt4/mkspecs/macx-g++ -o qwt_version_info.mak qwt_version_info.pro
/usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/unix.conf:
/usr/local/etc/qt4/mkspecs/common/mac.conf:
/usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/gcc-base.conf:
/usr/local/etc/qt4/mkspecs/common/gcc-base-macx.conf:
/usr/local/Cellar/qt@4/4.8.7_5/etc/qt4/mkspecs/common/g++-base.conf:
/usr/local/etc/qt4/mkspecs/common/g++-macx.conf:
qmake:  FORCE
    @$(QMAKE) -spec /usr/local/etc/qt4/mkspecs/macx-g++ -o qwt_version_info.mak qwt_version_info.pro


$(info Are we linking yet?2)

qwt_version_info.app/Contents/PkgInfo: 
    @$(CHK_DIR_EXISTS) qwt_version_info.app/Contents || $(MKDIR) qwt_version_info.app/Contents 
    @$(DEL_FILE) qwt_version_info.app/Contents/PkgInfo
    @echo "APPL????" >qwt_version_info.app/Contents/PkgInfo
qwt_version_info.app/Contents/Resources/empty.lproj: 
    @$(CHK_DIR_EXISTS) qwt_version_info.app/Contents/Resources || $(MKDIR) qwt_version_info.app/Contents/Resources 
    @touch qwt_version_info.app/Contents/Resources/empty.lproj

: 
    @$(DEL_FILE) 
    @sed -e "s,@SHORT_VERSION@,1.0,g" -e "s,@TYPEINFO@,????,g" -e "s,@ICON@,,g" -e "s,@EXECUTABLE@,qwt_version_info,g" -e "s,@TYPEINFO@,????,g"  >
dist: 
    @$(CHK_DIR_EXISTS) .tmp/qwt_version_info1.0.0 || $(MKDIR) .tmp/qwt_version_info1.0.0 
    $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qwt_version_info1.0.0/ && (cd `dirname .tmp/qwt_version_info1.0.0` && $(TAR) qwt_version_info1.0.0.tar qwt_version_info1.0.0 && $(COMPRESS) qwt_version_info1.0.0.tar) && $(MOVE) `dirname .tmp/qwt_version_info1.0.0`/qwt_version_info1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qwt_version_info1.0.0

$(info Are we linking yet?3)

clean:compiler_clean 
    -$(DEL_FILE) $(OBJECTS)
    -$(DEL_FILE) *~ core *.core


####### Sub-libraries

distclean: clean
    -$(DEL_FILE) -r qwt_version_info.app
    -$(DEL_FILE) qwt_version_info.mak


compiler_clean: 

####### Compile

$(info Are we linking yet?4)
qwt_version_info.o: qwt_version_info.cpp 
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o qwt_version_info.o qwt_version_info.cpp

$(info Are we linking yet?5)
####### Install

install:   FORCE

uninstall:   FORCE

FORCE:

非常感谢任何帮助。

更新: 在下面 /usr/local/Cellar/qt@4/4.8.7_5/lib/QtCore.framework 我找到了一个名为 QtCore 的二进制文件。我将其重命名为 libQtCore.so,当我将其与此二进制文件链接时,这是我的新错误消息:

$ g++ -v -headerpad_max_install_names -o qwt_version_info.app/Contents/MacOS/qwt_version_info qwt_version_info.o  -L/usr/local/Cellar/qt@4/4.8.7_5/lib/QtCore.framework -lQtCore

 "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -headerpad_max_install_names -macosx_version_min 10.14.0 -o qwt_version_info.app/Contents/MacOS/qwt_version_info -L/usr/local/Cellar/qt@4/4.8.7_5/lib/QtCore.framework qwt_version_info.o -lQtCore -lc++ -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)", referenced from:
      QTypedArrayData<unsigned short>::deallocate(QArrayData*) in qwt_version_info.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

现在我只需要帮助找到 QArrayData 符号的库二进制文件在哪里。我无法在 google.

上找到任何有用的信息

这可能还不是完整的答案,但它太大了,无法放入评论中。

所以让我们关注这里的单行:

g++ -v -headerpad_max_install_names -o qwt_version_info.app/Contents/MacOS/qwt_version_info qwt_version_info.o      

现在您将获得对以下内容的未定义引用:QByteArray 和 QTextStream。这些都存在于库 (IIRC) qtxcore 或 qtxcored(调试)中,其中 x 是 qt 版本。所以我想对你来说是 libqt4core.solibqt4cored.so.

所以我们需要两位信息,我们需要知道这是在哪里安装的以及您拥有哪种类型(调试或发布)。

图书馆通常在 /usr/lib/... 的某个地方,您会在其中的某个地方找到 libqt5core[d].so(IIRC /usr/lib/qt4/ - 但这是一个猜测)。

假设您有调试库 - 但两者都可能存在,然后我们可以 link 将该库添加到您的 linker 行:

注意:只需运行这一行手动开始,然后我们将把它添加到您的 makefile 中。

g++ -v -headerpad_max_install_names -o qwt_version_info.app/Contents/MacOS/qwt_version_info qwt_version_info.o -L/usr/lib/qt4 -lqt4cored

在这里你可以看到我们添加了库所在的路径 (-L...) 和库本身 (-l...)。

现在这将使您的 linker 能够找到 QByteArray 等...但是您可能还缺少一些东西,具体取决于您使用的 Qt 的哪些部分。以下是您可能需要添加的其他可能库的列表:

libQt4Gui.so
libQt4Core.so
libQt4DBus.so
libQt4PrintSupport.so
libQt4Widgets.so
libQt4Network.so
libQt4XcbQpa.so
libQt4Svg.so
libicui18n.so
libicuuc.so
libicudata.so

注意: 我从很久以前回答的另一个问题中得到了这个列表,所以它可能需要编辑,你可能想要也可能不想使用调试版本(例如 libQt5Gui.so -> libQt5Guid.so)。排名不分先后。

所以你最终可能会得到:

g++ -v -headerpad_max_install_names -o qwt_version_info.app/Contents/MacOS/qwt_version_info qwt_version_info.o -L/usr/lib/qt4 -lqt4cored -licudata -licuuc ... etc...

让这一行工作,然后我们可以看到如何将它添加到您的 makefile - 添加 libs/paths 是微不足道的。