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

C++ 架构x86_64的未定义符号:链接错误,c++,macos,qt,cmake,C++,Macos,Qt,Cmake,我有一个stellarium插件,它在Ubuntu上构建得很好,但当我试图在MacOSX上构建它时会抛出一个错误。我试图更改CMakeLists.txt文件以使其在OSX上兼容,但我反复遇到相同的错误。我收到的信息是: [ 18%] Linking CXX shared module libOpenSkyPlanetarium.so ld: warning: directory not found for option '-L/src' Undefined symbols for archite

我有一个stellarium插件,它在Ubuntu上构建得很好,但当我试图在MacOSX上构建它时会抛出一个错误。我试图更改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
文件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/)

您如何看待此错误:
ld:warning:未找到选项'-L/src'的目录。
是否可以发布CMake配置消息。生成过程似乎缺少某些环境变量。出现问题的行位于CMakeLists.txt中:“LINK_DIRECTORIES(${build_DIR}/src)”尝试打印“build_DIR”的值。类似于“message”(“Build Dir是:“${Build_Dir}”)在你身上。txt@AmeyaVS我试着打印它,但它返回一个空字符串。我也试过其他内置插件,但同样的事情发生了。你能在Ubuntu中尝试一下,看看有什么不同。运行make命令如下:make VERBOSE=1,它将显示完整的编译命令行。比较两个插件的日志cOSX与Ubuntu
# 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/)