ModalAI Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Ceres c++ error when used in voxl2 project

    Ask your questions right here!
    2
    9
    280
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      lfierz
      last edited by

      Hi there

      I am running a structure from motion pipeline on voxl2 and this pipeline needs in a prior step the bundle adjustment solver Ceres. I know that on voxl this pipeline worked but now for some reason on voxl2 I can build Ceres but when building the project that depends on Ceres I get an error saying that the std::vector = operator is an undefined reference. (see attached image)

      Screenshot from 2023-11-20 15-33-21.png

      Any ideas how to resolve this? I tried moving from c++ 11 in the cmake to c++14 but I think that's a bad approach as the assignment operator for std::vectors was introduced in c++ 98. I also tried using a specific voxl Ceres that I built using voxl docker but that yielded many other errors indicating a doubtful implementation.

      Any ideas how to resolve this? Thanks in advance.

      Alex KushleyevA 1 Reply Last reply Reply Quote 0
      • Alex KushleyevA
        Alex Kushleyev ModalAI Team @lfierz
        last edited by

        @lfierz , this could happen if you built Ceres using a different build environment (different version of gcc / libstdc++). Are you building Ceres and your project natively on VOXL2 with the same C++ dialect?

        Alex

        L 1 Reply Last reply Reply Quote 0
        • L
          lfierz @Alex Kushleyev
          last edited by

          @Alex-Kushleyev I'm not exactly sure what to look for when looking for the c++ dialect used. There are no CXX_STANDARD statements in either CMakeLists.txt file. So I suppose they are both using the default (don't know what that is).

          My project does use C++14 while Ceres 1.14 which I try to include uses c++11 but I tried with c++14 there as well as mentioned previously yielding the same error.

          Alex KushleyevA 1 Reply Last reply Reply Quote 0
          • Alex KushleyevA
            Alex Kushleyev ModalAI Team @lfierz
            last edited by

            @lfierz also please double check that you are linking against libstdc++ ..

            Additionally, since it seems you are using a static library libceres.a , with static libraries, the link order matters, so make sure that -lstdc++ is after -lceres in your link command.

            L 2 Replies Last reply Reply Quote 0
            • L
              lfierz @Alex Kushleyev
              last edited by

              @Alex-Kushleyev Thanks for the hint. I now added the stdc++ to the linked libs like so:
              target_link_libraries(${PROJECT_NAME}_tracker_node stdc++ ${CERES_LIBRARIES})
              It still yields the same error sadly. I also tried linking stdc++ in a separate target_link_libraries statement which also yielded the same error.

              Alex KushleyevA 1 Reply Last reply Reply Quote 0
              • L
                lfierz @Alex Kushleyev
                last edited by lfierz

                @Alex-Kushleyev I'm quite sure that I use the g++ compiler for both builds. neither clang nor msvc are installed.

                1 Reply Last reply Reply Quote 0
                • Alex KushleyevA
                  Alex Kushleyev ModalAI Team @lfierz
                  last edited by Alex Kushleyev

                  @lfierz said in Ceres c++ error when used in voxl2 project:

                  target_link_libraries(${PROJECT_NAME}_tracker_node stdc++ ${CERES_LIBRARIES})

                  please try to switch link order of the libraries, specifically:

                  target_link_libraries(${PROJECT_NAME}_tracker_node ${CERES_LIBRARIES} stdc++)
                  

                  The static libraries should come first. see https://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc

                  also, if you enable verbose cmake, you can actually see the linker command and make sure it has -lceres -lstdc++ in that order

                  Alternatively.. if you build Ceres as dynamic library, it should figure out the dependencies at run time..

                  L 1 Reply Last reply Reply Quote 0
                  • L
                    lfierz @Alex Kushleyev
                    last edited by

                    @Alex-Kushleyev building Ceres as a dynamically linked library solved it. You are hero material thank you!

                    Alex KushleyevA 1 Reply Last reply Reply Quote 0
                    • Alex KushleyevA
                      Alex Kushleyev ModalAI Team @lfierz
                      last edited by

                      @lfierz , excellent! I am glad that it worked 🙂

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB | Contributors