Linking Error on Building a plugin on Mac OSX

Asked by Saloni Mundra on 2017-06-01

I have a plugin for stellarium that builds fine on Ubuntu but throws an error when I try to build it on Mac OSX. I tried to change the CMakeLists.txt files to make it compatible on OSX but I repeatedly get the same errors. The messages I receive are:

[ 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

I followed these steps after copying my plugin into stellarium's plugins folder:

mkdir -p builds/unix
cd builds/unix
cmake ../..
make

These are the CMakeLists.txt files:

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})

File 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/)

Question information

Language:
English Edit question
Status:
Answered
For:
Stellarium Edit question
Assignee:
No assignee Edit question
Last query:
2017-06-01
Last reply:
2017-06-05
gzotti (georg-zotti) said : #1

ld: warning: directory not found for option '-L/src' ???

Saloni Mundra (salonimundra) said : #2

@gzotti What does this line mean and how do I solve it?

gzotti (georg-zotti) said : #3

The linker cannot find anything in /src. /src is a subdirectory of the top level (root directory).

From the last lines above, it may be that you need to set variable CMAKE_SOURCE_DIR so that ${CMAKE_SOURCE_DIR}/src can be resolved.

Indeed, the line above that:
SET(STELLARIUM_SOURCE_DIR $ENV{STELROOT})

commands cmake to set its variable STELLARIUM_SOURCE_DIR from the environment variable STELROOT. So, set that environment variable and you should be up and running.

Saloni Mundra (salonimundra) said : #4

Can you let me know how to do it? I am new to stellarium and need to fix the problem ASAP. Thanks in advance.

gzotti (georg-zotti) said : #5

Instructions on https://github.com/harpreetrathore/Openskyplanetarium

are pretty clear. I don't have a Mac and don't know if working with a folder $STELROOT/builds/macosx will be enough.

Something like typing

export STELROOT=/path/to/stellarium_sources

in a terminal should be enough to set it for that terminal session.

I don't know how you set an environment variable system-wide on MacOSX. But I am certain your favourite search engine will know it.

Saloni Mundra (salonimundra) said : #6

I have already implemented it. I have followed the instructions specified on https://github.com/harpreetrathore/Openskyplanetarium
and it compiles fine on an Ubuntu machine, but the same thing does not work on Mac OSX.

Can you help with this problem?

Provide an answer of your own, or ask Saloni Mundra for more information if necessary.

To post a message you must log in.