×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Trouble Linking Libraries

  • Posts: 19
  • Thank you received: 3
I am currently trying to write code in C++ to control my telescope. I was able to follow the instructions on github to install libindi with cmake but I am having trouble running the tutorials with my own cmake file. I keep getting undefined references to all the functions in libindi even though it appears to be linked properly.

this is my error log.

CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `main':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:19: multiple definition of `main'
CMakeFiles/pandaScope.dir/src/main.cpp.o:/home/cassidy/CLionProjects/PalskiScope/src/main.cpp:37: first defined here
CMakeFiles/pandaScope.dir/src/main.cpp.o: In function `main':
/home/cassidy/CLionProjects/PalskiScope/src/main.cpp:74: undefined reference to `test()'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::newDevice(INDI::BaseDevice*)':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:84: undefined reference to `INDI::BaseDevice::getDeviceName()'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::newNumber(_INumberVectorProperty*)':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:65: undefined reference to `INDI::BaseDevice::getNumber(char const*)'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::newProperty(INDI::Property*)':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:94: undefined reference to `INDI::Property::getDeviceName() const'
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:94: undefined reference to `INDI::Property::getName() const'
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:100: undefined reference to `INDI::Property::getDeviceName() const'
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:100: undefined reference to `INDI::Property::getName() const'
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:102: undefined reference to `INDI::BaseDevice::isConnected()'
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:46: undefined reference to `INDI::BaseDevice::getNumber(char const*)'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::MyClient()':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:35: undefined reference to `INDI::BaseClient::BaseClient()'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::setTemperature()':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:46: undefined reference to `INDI::BaseDevice::getNumber(char const*)'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::takeExposure()':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:65: undefined reference to `INDI::BaseDevice::getNumber(char const*)'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::newMessage(INDI::BaseDevice*, int)':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:132: undefined reference to `INDI::BaseDevice::getDeviceName()'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::newNumber(_INumberVectorProperty*)':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:77: undefined reference to `INDI::BaseClient::sendNewNumber(_INumberVectorProperty*)'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::newProperty(INDI::Property*)':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:56: undefined reference to `INDI::BaseClient::sendNewNumber(_INumberVectorProperty*)'
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:96: undefined reference to `INDI::BaseClient::connectDevice(char const*)'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::setTemperature()':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:56: undefined reference to `INDI::BaseClient::sendNewNumber(_INumberVectorProperty*)'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::takeExposure()':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:77: undefined reference to `INDI::BaseClient::sendNewNumber(_INumberVectorProperty*)'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::~MyClient()':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.hpp:24: undefined reference to `INDI::BaseClient::~BaseClient()'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `MyClient::~MyClient()':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.hpp:24: undefined reference to `INDI::BaseClient::~BaseClient()'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `std::unique_ptr<MyClient, std::default_delete<MyClient> >::~unique_ptr()':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.hpp:24: undefined reference to `INDI::BaseClient::~BaseClient()'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `main':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:20: undefined reference to `INDI::BaseClient::setServer(char const*, unsigned int)'
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:22: undefined reference to `INDI::BaseClient::watchDevice(char const*)'
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:24: undefined reference to `INDI::BaseClient::connectServer()'
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:26: undefined reference to `INDI::BaseClient::setBLOBMode(BLOBHandling, char const*, char const*)'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o: In function `__static_initialization_and_destruction_0':
/home/cassidy/CLionProjects/PalskiScope/src/telescope/functions.cpp:35: undefined reference to `INDI::BaseClient::BaseClient()'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o:(.data.rel.ro._ZTI8MyClient[_ZTI8MyClient]+0x10): undefined reference to `typeinfo for INDI::BaseClient'
CMakeFiles/pandaScope.dir/src/telescope/functions.cpp.o:(.data.rel.ro._ZTV8MyClient[_ZTV8MyClient]+0x80): undefined reference to `INDI::BaseClient::newUniversalMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
4 years 7 months ago #41709

Please Log in or Create an account to join the conversation.

You're trying to make a client? Ok, share your CMakelists.txt
4 years 7 months ago #41731

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 3

Replied by Greg on topic Trouble Linking Libraries

cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
project(pandaScope)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_CFLAGS} -O3 -Wall")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules)

find_package(OpenCV REQUIRED)
find_package(GSL REQUIRED)
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
find_package(Boost REQUIRED)
find_package(INDI 1.7 REQUIRED)

add_library(cspice STATIC IMPORTED)

set_property(TARGET
cspice
PROPERTY
IMPORTED_LOCATION
/usr/lib/cspice.a)

INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )

include_directories(${INDI_INCLUDE_DIR})

IF (CMAKE_BUILD_TYPE MATCHES COVERAGE)
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
ENDIF (CMAKE_BUILD_TYPE MATCHES COVERAGE)

set(SOURCE ${SOURCE}
src/main.cpp
src/focus/focuser.cpp
src/detection/detection.cpp
src/iod/state_generation.cpp
src/iod/lambert_gooding.cpp
src/batch/lambert.cpp
src/batch/batch.cpp
src/utilities/conversions.cpp
src/utilities/kernels.cpp
src/batch/propagator.cpp
src/telescope/functions.cpp
src/telescope/operation.cpp)

set(HEADERS ${HEADERS}
src/includes.hpp
src/focus/focuser.hpp
src/detection/detection.hpp
src/iod/state_generation.hpp
src/iod/lambert_gooding.hpp
dependencies/cxxopts.hpp
src/batch/lambert.hpp
src/batch/batch.hpp
src/utilities/conversions.hpp
src/utilities/vectors.hpp
src/utilities/kernels.hpp
src/batch/propagator.hpp
src/telescope/functions.hpp
src/telescope/operation.hpp)

add_subdirectory(testing)

add_executable(pandaScope ${SOURCE} ${HEADERS})

target_link_libraries(pandaScope ${OpenCV_LIBS})
target_link_libraries(pandaScope usbp-1)
target_link_libraries(pandaScope GSL::gsl GSL::gslcblas)
target_link_libraries(pandaScope Eigen3::Eigen)
target_link_libraries(pandaScope LINK_PUBLIC ${Boost_LIBRARIES})
target_link_libraries(pandaScope cspice)
target_link_libraries(pandaScope ${INDI_LIBRARIES})
4 years 7 months ago #41768

Please Log in or Create an account to join the conversation.

Thanks. Please confirm whether you are developing a Driver to communicate with hardware or a Client that communicates with INDI server?
4 years 7 months ago #41769

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 3

Replied by Greg on topic Trouble Linking Libraries

I am trying to create a client that communicates with the server.
4 years 7 months ago #41778

Please Log in or Create an account to join the conversation.

You need to add these:
find_package(Nova REQUIRED)
include_directories(${NOVA_INCLUDE_DIR})

Then link with INDI Client library, not INDI_LIBRARIES which are used by drivers.
target_link_libraries(pandaScope ${INDI_CLIENT_LIBRARIES} ${NOVA_LIBRARIES} z)
4 years 7 months ago #41781

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 3

Replied by Greg on topic Trouble Linking Libraries

I added the lines to my CMakeLists but I am still getting build errors. Here is my updated CMake file

cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
project(pandaScope)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_CFLAGS} -O3 -Wall")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules)

find_package(OpenCV REQUIRED)
find_package(GSL REQUIRED)
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
find_package(Boost REQUIRED)
find_package(INDI 1.7 REQUIRED)
find_package(Nova REQUIRED)
find_package(CFITSIO REQUIRED)

add_library(cspice STATIC IMPORTED)

set_property(TARGET
cspice
PROPERTY
IMPORTED_LOCATION
/usr/lib/cspice.a)

INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
include_directories(${INDI_INCLUDE_DIR})
include_directories(${NOVA_INCLUDE_DIR})
include_directories(${CFITSIO_INCLUDE_DIR})

IF (CMAKE_BUILD_TYPE MATCHES COVERAGE)
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
ENDIF (CMAKE_BUILD_TYPE MATCHES COVERAGE)

set(SOURCE ${SOURCE}
src/main.cpp
src/focus/focuser.cpp
src/detection/detection.cpp
src/iod/state_generation.cpp
src/iod/lambert_gooding.cpp
src/batch/lambert.cpp
src/batch/batch.cpp
src/utilities/conversions.cpp
src/utilities/kernels.cpp
src/batch/propagator.cpp
src/telescope/functions.cpp
src/telescope/operation.cpp)

set(HEADERS ${HEADERS}
src/includes.hpp
src/focus/focuser.hpp
src/detection/detection.hpp
src/iod/state_generation.hpp
src/iod/lambert_gooding.hpp
dependencies/cxxopts.hpp
src/batch/lambert.hpp
src/batch/batch.hpp
src/utilities/conversions.hpp
src/utilities/vectors.hpp
src/utilities/kernels.hpp
src/batch/propagator.hpp
src/telescope/functions.hpp
src/telescope/operation.hpp)

add_subdirectory(testing)

add_executable(pandaScope ${SOURCE} ${HEADERS})

target_link_libraries(pandaScope ${OpenCV_LIBS})
target_link_libraries(pandaScope usbp-1)
target_link_libraries(pandaScope GSL::gsl GSL::gslcblas)
target_link_libraries(pandaScope Eigen3::Eigen)
target_link_libraries(pandaScope LINK_PUBLIC ${Boost_LIBRARIES})
target_link_libraries(pandaScope cspice)
target_link_libraries(pandaScope ${INDI_CLIENT_LIBRARIES})
target_link_libraries(pandaScope ${INDI_LIBRARIES})
target_link_libraries(pandaScope ${NOVA_LIBRARIES})
target_link_libraries(pandaScope ${CFITSIO_LIBRARIES})
4 years 7 months ago #41782

Please Log in or Create an account to join the conversation.

remove INDI_LIBRARIES

is your project hosted somewhere? I can clone it and see if there are any errors.
4 years 7 months ago #41790

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 3

Replied by Greg on topic Trouble Linking Libraries

I did remove INDI_LIBRARIES and still had the same error. I unfortunately not hosting this anywhere. Could the issue be stemming from this being the client tutorial code? Does it require information from the other tutorials? I was able to run all of the tutorials individually, but I am having issues putting that code in my project as a framework to follow.
4 years 7 months ago #41793

Please Log in or Create an account to join the conversation.

Not sure, it should work. Are you getting exactly the same linkage errors as your first post? Try moving ${INDI_CLIENT_LIBRARIES} to be the first (or last) library to be linked with. Sometimes order does matter.
4 years 7 months ago #41806

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 3

Replied by Greg on topic Trouble Linking Libraries

Moving the INDI_CLIENT_LIBRARIES to be first or last didn't solve anything. Removing INDI_LIBRARIES seems to generate more errors. I am attaching error logs that include my cmake lists file. I will also attach my source and header files that include the client code to make sure I'm not missing anything there.
4 years 7 months ago #41814
Attachments:

Please Log in or Create an account to join the conversation.

Can you make a minimal project and test the CMake and then zip it and share that? If the minimal project produces the same issue, then I can identify what's wrong and tell you how to proceed.
4 years 7 months ago #41822

Please Log in or Create an account to join the conversation.

Time to create page: 0.934 seconds