# Ceres c++ error when used in voxl2 project

Source: https://forum.modalai.com/topic/2912/ceres-c-error-when-used-in-voxl2-project
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2023-11-30 21:43:00 UTC by lfierz
Replies: 8 · Views: 978

## lfierz · 2023-11-30 21:43:00 UTC

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](https://forum.modalai.com/assets/uploads/files/1701380397567-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.

## Reply by Alex Kushleyev (ModalAI staff) · 2023-11-30 21:56:53 UTC

@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

## Reply by lfierz · 2023-11-30 22:10:00 UTC (in reply to Alex Kushleyev)

@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.

## Reply by Alex Kushleyev (ModalAI staff) · 2023-11-30 22:18:00 UTC (in reply to lfierz)

@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.

## Reply by lfierz · 2023-11-30 23:05:40 UTC (in reply to Alex Kushleyev)

@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.

## Reply by lfierz · 2023-11-30 23:28:52 UTC (in reply to Alex Kushleyev)

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

## Reply by Alex Kushleyev (ModalAI staff) · 2023-12-01 02:13:43 UTC (in reply to lfierz)

@lfierz said in [Ceres c\+\+ error when used in voxl2 project](/post/13408):
> 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..

## Reply by lfierz · 2023-12-04 22:46:14 UTC (in reply to Alex Kushleyev)

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

## Reply by Alex Kushleyev (ModalAI staff) · 2023-12-05 16:57:28 UTC (in reply to lfierz)

@lfierz , excellent! I am glad that it worked :)
