架构x86_64的未定义符号:链接错误

时间:2017-05-30 06:08:57

标签: c++ macos qt cmake

我有一个stellarium插件,可以在Ubuntu上构建得很好,但是当我尝试在Mac OSX上构建它时会抛出错误。我试图更改CMakeLists.txt文件以使其在OSX上兼容但我反复得到相同的错误。我收到的消息是:

[ 18%] Linking CXX shared module libOpenSkyPlanetarium.so
ld: warning: directory not found for option '-L/src'
Undefined symbols for architecture x86_64:
  "StelButton::StelButton(QGraphicsItem*, QPixmap const&, QPixmap const&, QPixmap const&, QString const&, bool)", referenced from:
      OpenSkyPlanetarium::init() in OpenSkyPlanetarium.cpp.o
  "StelDialog::qt_metacall(QMetaObject::Call, int, void**)", referenced from:
      OSPMainDialog::qt_metacall(QMetaObject::Call, int, void**) in moc_compilation.cpp.o
  "StelDialog::qt_metacast(char const*)", referenced from:
      OSPMainDialog::qt_metacast(char const*) in moc_compilation.cpp.o
  "StelDialog::staticMetaObject", referenced from:
      OSPMainDialog::staticMetaObject in moc_compilation.cpp.o
  "StelDialog::StelDialog(QString, QObject*)", referenced from:
      OSPMainDialog::OSPMainDialog() in OSPMainDialog.cpp.o
  "StelDialog::~StelDialog()", referenced from:
      OSPMainDialog::OSPMainDialog() in OSPMainDialog.cpp.o
      OSPMainDialog::~OSPMainDialog() in OSPMainDialog.cpp.o
  "StelModule::qt_metacall(QMetaObject::Call, int, void**)", referenced from:
      OpenSkyPlanetarium::qt_metacall(QMetaObject::Call, int, void**) in moc_compilation.cpp.o
  "StelModule::qt_metacast(char const*)", referenced from:
      OpenSkyPlanetarium::qt_metacast(char const*) in moc_compilation.cpp.o
  "StelModule::staticMetaObject", referenced from:
      OpenSkyPlanetarium::staticMetaObject in moc_compilation.cpp.o
  "StelModule::addAction(QString const&, QString const&, QString const&, QObject*, char const*, QString const&, QString const&)", referenced from:
      OpenSkyPlanetarium::init() in OpenSkyPlanetarium.cpp.o
  "StelModule::StelModule()", referenced from:
      OpenSkyPlanetarium::OpenSkyPlanetarium() in OpenSkyPlanetarium.cpp.o
  "QSerialPort::setPortName(QString const&)", referenced from:
      SerialCom::run() in SerialCom.cpp.o
  "QSerialPort::waitForReadyRead(int)", referenced from:
      SerialCom::run() in SerialCom.cpp.o
  "QSerialPort::waitForBytesWritten(int)", referenced from:
      SerialCom::run() in SerialCom.cpp.o
  "QSerialPort::open(QFlags<QIODevice::OpenModeFlag>)", referenced from:
      SerialCom::run() in SerialCom.cpp.o
  "QSerialPort::close()", referenced from:
      SerialCom::run() in SerialCom.cpp.o
  "QSerialPort::QSerialPort(QObject*)", referenced from:
      SerialCom::run() in SerialCom.cpp.o
  "QSerialPort::~QSerialPort()", referenced from:
      SerialCom::run() in SerialCom.cpp.o
  "StelFileMgr::getUserDir()", referenced from:
      OSPMainDialog::OSPMainDialog() in OSPMainDialog.cpp.o
  "StelFileMgr::mkDir(QString const&)", referenced from:
      OSPMainDialog::OSPMainDialog() in OSPMainDialog.cpp.o
  "StelFileMgr::exists(QString const&)", referenced from:
      OSPMainDialog::OSPMainDialog() in OSPMainDialog.cpp.o
  "BottomStelBar::addButton(StelButton*, QString const&, QString const&)", referenced from:
      OpenSkyPlanetarium::init() in OpenSkyPlanetarium.cpp.o
  "StelModuleMgr::getModule(QString const&, bool)", referenced from:
      OpenSkyPlanetarium::getCallOrder(StelModule::StelModuleActionName) const in OpenSkyPlanetarium.cpp.o
      OSPMainDialog::setReference() in OSPMainDialog.cpp.o
      OSPMainDialog::goTo() in OSPMainDialog.cpp.o
      OSPMainDialog::compileScript() in OSPMainDialog.cpp.o
      OSPMainDialog::gt() in OSPMainDialog.cpp.o
  "QSerialPortInfo::availablePorts()", referenced from:
      OSPMainDialog::selectDevice() in OSPMainDialog.cpp.o
  "QSerialPortInfo::QSerialPortInfo(QSerialPortInfo const&)", referenced from:
      QList<QSerialPortInfo>::node_copy(QList<QSerialPortInfo>::Node*, QList<QSerialPortInfo>::Node*, QList<QSerialPortInfo>::Node*) in OSPMainDialog.cpp.o
  "QSerialPortInfo::~QSerialPortInfo()", referenced from:
      QList<QSerialPortInfo>::node_copy(QList<QSerialPortInfo>::Node*, QList<QSerialPortInfo>::Node*, QList<QSerialPortInfo>::Node*) in OSPMainDialog.cpp.o
      QList<QSerialPortInfo>::node_destruct(QList<QSerialPortInfo>::Node*, QList<QSerialPortInfo>::Node*) in OSPMainDialog.cpp.o
  "StelApp::singleton", referenced from:
      StelApp::getInstance() in OpenSkyPlanetarium.cpp.o
      StelApp::getInstance() in OSPMainDialog.cpp.o
  "StelUtils::rectToSphe(double*, double*, Vector3<double> const&)", referenced from:
      OSPMainDialog::setReference() in OSPMainDialog.cpp.o
      OSPMainDialog::goTo() in OSPMainDialog.cpp.o
      OSPMainDialog::compileScript() in OSPMainDialog.cpp.o
      OSPMainDialog::gt() in OSPMainDialog.cpp.o
  "StelUtils::hmsToRad(unsigned int, unsigned int, double)", referenced from:
      OSPMainDialog::initDevice() in OSPMainDialog.cpp.o
      OSPMainDialog::setReference() in OSPMainDialog.cpp.o
      OSPMainDialog::goTo() in OSPMainDialog.cpp.o
      OSPMainDialog::move(QString, QString) in OSPMainDialog.cpp.o
  "StelModule::getModuleVersion() const", referenced from:
      vtable for OpenSkyPlanetarium in moc_compilation.cpp.o
  "StelObject::getEquinoxEquatorialPos(StelCore const*) const", referenced from:
      OSPMainDialog::setReference() in OSPMainDialog.cpp.o
      OSPMainDialog::goTo() in OSPMainDialog.cpp.o
      OSPMainDialog::compileScript() in OSPMainDialog.cpp.o
      OSPMainDialog::gt() in OSPMainDialog.cpp.o
  "QSerialPort::error() const", referenced from:
      SerialCom::run() in SerialCom.cpp.o
  "StelObjectMgr::searchByNameI18n(QString const&) const", referenced from:
      OSPMainDialog::compileScript() in OSPMainDialog.cpp.o
  "QSerialPortInfo::portName() const", referenced from:
      OSPMainDialog::selectDevice() in OSPMainDialog.cpp.o
  "StelGui::getButtonBar() const", referenced from:
      OpenSkyPlanetarium::init() in OpenSkyPlanetarium.cpp.o
  "typeinfo for StelDialog", referenced from:
      typeinfo for OSPMainDialog in moc_compilation.cpp.o
  "typeinfo for StelModule", referenced from:
      typeinfo for OpenSkyPlanetarium in moc_compilation.cpp.o
  "typeinfo for StelGuiBase", referenced from:
      OpenSkyPlanetarium::init() in OpenSkyPlanetarium.cpp.o
  "typeinfo for StelGui", referenced from:
      OpenSkyPlanetarium::init() in OpenSkyPlanetarium.cpp.o
  "vtable for StelModule", referenced from:
      StelModule::~StelModule() in OpenSkyPlanetarium.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for BarFrame", referenced from:
      BarFrame::BarFrame(QWidget*) in OSPMainDialog.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/libOpenSkyPlanetarium.so] Error 1
make[1]: *** [src/CMakeFiles/OpenSkyPlanetarium-static.dir/all] Error 2
make: *** [all] Error 2

我将插件复制到stellarium的插件文件夹后,我按照以下步骤操作:

  1. mkdir -p builds / unix
  2. cd builds / unix
  3. cmake ../..
  4. 使
  5. 我检查了这些帖子,但解决方案无效:

    1. "Undefined symbols for architecture x86_64:"

    2. Qt Creator: Undefined symbols for architecture x86_64

    3. 这些是CMakeLists.txt文件

      INCLUDE_DIRECTORIES(.)
      
      LINK_DIRECTORIES(${BUILD_DIR}/src)
      
      SET(OpenSkyPlanetarium_SRCS
           OpenSkyPlanetarium.hpp
           OpenSkyPlanetarium.cpp
           LaserDev.hpp
           LaserDev.cpp
           Calibrate.hpp
           Calibrate.cpp
           SerialCom.hpp
           SerialCom.cpp
           gui/OSPMainDialog.hpp
           gui/OSPMainDialog.cpp
      )
      
      SET(OpenSkyPlanetarium_UIS
           gui/OSPMainDialog.ui
      )
      
      SET(OpenSkyPlanetarium_RES
           ../OpenSkyPlanetarium.qrc
      )
      QT5_ADD_RESOURCES(OpenSkyPlanetarium_RES_CXX ${OpenSkyPlanetarium_RES})
      
      # Wrapping UI
      QT5_WRAP_UI(OpenSkyPlanetarium_UIS_H ${OpenSkyPlanetarium_UIS})
      
      
      # Library Properties
      ADD_LIBRARY(OpenSkyPlanetarium-static MODULE
      ${OpenSkyPlanetarium_SRCS} ${OpenSkyPlanetarium_RES_CXX}
      ${OpenSkyPlanetarium_UIS_H})
      QT5_USE_MODULES(OpenSkyPlanetarium-static Core Gui Widgets Multimedia)
      SET_TARGET_PROPERTIES(OpenSkyPlanetarium-static PROPERTIES OUTPUT_NAME
      "OpenSkyPlanetarium" AUTOMOC TRUE COMPILE_FLAGS "-DQT_OSP")
      TARGET_LINK_LIBRARIES(OpenSkyPlanetarium-static ${extLinkerOption})
      

      文件2:

      # This is the cmake config file for the OpenSkyPlanetarium
      CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
      SET(OPENSKYPLANETARIUM_VERSION "0.1.0")
      FIND_PACKAGE(Qt5Core REQUIRED)
      FIND_PACKAGE(Qt5Gui REQUIRED)
      FIND_PACKAGE(Qt5OpenGL REQUIRED)
      
      SET(STELLARIUM_SOURCE_DIR $ENV{STELROOT})
      
      INCLUDE_DIRECTORIES(
          ${CMAKE_BINARY_DIR}
          ${CMAKE_SOURCE_DIR}/src
          ${CMAKE_SOURCE_DIR}/src/gui
          ${STELLARIUM_SOURCE_DIR}/src
          ${STELLARIUM_SOURCE_DIR}/src/core
          ${STELLARIUM_SOURCE_DIR}/src/core/modules
          ${STELLARIUM_SOURCE_DIR}/src/core/planetsephems
          ${STELLARIUM_SOURCE_DIR}/src/core/external
          ${STELLARIUM_SOURCE_DIR}/src/core/external/qtcompress
          ${STELLARIUM_SOURCE_DIR}/src/core/external/glues_stel/source/
          ${STELLARIUM_SOURCE_DIR}/src/core/external/glues_stel/source/libtess
          ${STELLARIUM_SOURCE_DIR}/src/gui
          ${STELLARIUM_SOURCE_DIR}/src/scripting
          ${INTL_INCLUDE_DIR}
          ${CMAKE_BINARY_DIR}/src
          ${ZLIB_INCLUDE_DIR}
      )
      
      ADD_SUBDIRECTORY( src )
      
      SET(QT_LINK_PARAMETERS Qt5::Core Qt5::Gui Qt5::OpenGL)
      
      SET(CMAKE_INSTALL_PREFIX $ENV{HOME}/.stellarium)
      
      install(FILES DESTINATION modules/OpenSkyPlanetarium/)
      

0 个答案:

没有答案