/usr/bin/ld: CMakeFiles/car_controller_new.dir/src/car_controller_new.cpp.o: in function `L1Controller::L1Controller()'报错
时间: 2023-06-07 10:07:40 浏览: 203
这个报错表示在编译时在 car_controller_new.cpp.o 文件中的 L1Controller 函数出现了错误。具体原因需要查看代码和编译器的详细信息。您可以尝试重新编译程序并查看更详细的错误信息,以便更好地解决这个问题。
相关问题
usr/bin/ld: CMakeFiles/AVM_HIKVISION.dir/src/captures.cpp.o:(.bss+0x0): multiple definition of `last'; CMakeFiles/AVM_HIKVISION.dir/src/main.cpp.o:(.bss+0x0): first defined here /usr/bin/ld: CMakeFiles/AVM_HIKVISION.dir/include/AVM/birdview.cpp.o:(.bss+0x0): multiple definition of `last'; CMakeFiles/AVM_HIKVISION.dir/src/main.cpp.o:(.bss+0x0): first defined here /usr/bin/ld: CMakeFiles/AVM_HIKVISION.dir/src/mediawall.cpp.o:(.bss+0x0): multiple definition of `last'; CMakeFiles/AVM_HIKVISION.dir/src/main.cpp.o:(.bss+0x0): first defined here /usr/bin/ld: CMakeFiles/AVM_HIKVISION.dir/src/mediawall.cpp.o: in function `main': mediawall.cpp:(.text+0x137f): multiple definition of `main'; CMakeFiles/AVM_HIKVISION.dir/src/main.cpp.o:main.cpp:(.text+0x0): first defined here /usr/bin/ld: /home/wsh/software/media-server-avm1d/avm1d/lib/HCNet/libSophus.so: error adding symbols: file in wrong format collect2: error: ld returned 1 exit status 这个是什么错误
这个错误是链接器(ld)报告的错误。它指出在多个目标文件中存在相同的符号定义,导致重复定义。具体来说,`last`和`main`这两个符号在不同的目标文件中被定义了多次。
可能的原因是在编译过程中,多个源文件包含了同名的全局变量或函数,导致冲突。
解决这个问题的方法是确保每个符号只有一个定义。你可以检查你的代码,看看是否有重复定义的全局变量或函数。如果是意外的重复定义,你可以删除其中一个定义。如果是有意为之的重复定义,你可以将它们重命名以避免冲突。
另外,错误信息中还提到了一个文件格式错误(`file in wrong format`),可能是由于使用了不兼容的库文件导致的。你可以检查使用的库文件是否与你的项目兼容,并尝试使用正确的版本。
希望能帮到你!如果有任何更多的问题,请随时提问。
FAILED: MyTestHttp : && /usr/bin/c++ -g CMakeFiles/MyTestHttp.dir/main.cpp.o -o MyTestHttp && : /usr/bin/ld: CMakeFiles/MyTestHttp.dir/main.cpp.o: in function `Http::Http()': /home/hy-20/project/MyTestHttp/main.cpp:20: undefined reference to `curl_global_init' /usr/bin/ld: /home/hy-20/project/MyTestHttp/main.cpp:21: undefined reference to `curl_easy_init' /usr/bin/ld: CMakeFiles/MyTestHttp.dir/main.cpp.o: in function `Http::~Http()': /home/hy-20/project/MyTestHttp/main.cpp:25: undefined reference to `curl_easy_cleanup' /usr/bin/ld: /home/hy-20/project/MyTestHttp/main.cpp:26: undefined reference to `curl_global_cleanup' /usr/bin/ld: CMakeFiles/MyTestHttp.dir/main.cpp.o: in function `Http::setUrl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': /home/hy-20/project/MyTestHttp/main.cpp:29: undefined reference to `curl_easy_setopt' /usr/bin/ld: CMakeFiles/MyTestHttp.dir/main.cpp.o: in function `Http::setPostFields(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': /home/hy-20/project/MyTestHttp/main.cpp:31: undefined reference to `curl_easy_setopt' /usr/bin/ld: CMakeFiles/MyTestHttp.dir/main.cpp.o: in function `Http::setMethod(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': /home/hy-20/project/MyTestHttp/main.cpp:35: undefined reference to `curl_easy_setopt' /usr/bin/ld: /home/hy-20/project/MyTestHttp/main.cpp:36: undefined reference to `curl_easy_setopt' /usr/bin/ld: CMakeFiles/MyTestHttp.dir/main.cpp.o: in function `Http::setHeaders(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': /home/hy-20/project/MyTestHttp/main.cpp:41: undefined reference to `curl_slist_append' /usr/bin/ld: /home/hy-20/project/MyTestHttp/main.cpp:42: undefined reference to `curl_easy_setopt' /usr/bin/ld: CMakeFiles/MyTestHttp.dir/main.cpp.o: in function `Http::setWriteFunction(std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)> const&)': /home/hy-20/project/MyTestHttp/main.cpp:46: undefined reference to `curl_easy_setopt' /usr/bin/ld: /home/hy-20/project/MyTestHttp/main.cpp:47: undefined reference to `curl_easy_setopt' /usr/bin/ld: CMakeFiles/MyTestHttp.dir/main.cpp.o: in function `Http::perform()': /home/hy-20/project/MyTestHttp/main.cpp:50: undefined reference to `curl_easy_perform' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
这是一个链接错误,编译器找不到 curl 库的函数。你需要在链接时加上 curl 库。如果你使用的是 CMake,可以在 CMakeLists.txt 中添加以下代码:
```
find_package(CURL REQUIRED)
target_link_libraries(YourProjectName ${CURL_LIBRARIES})
```
其中,YourProjectName 是你的项目名称。
阅读全文