BehaviorTree / BehaviorTree.CPP

Behavior Trees Library in C++. Batteries included.
https://www.behaviortree.dev
MIT License
3.02k stars 661 forks source link

Building with WSL does not work #868

Open jerylteo opened 1 month ago

jerylteo commented 1 month ago

Running WSL on Windows 11, on BehaviorTree.CPP v4.6.2.

Continuation from #867

Commands to build works without errors, but folder does not reflect built files. i.e. No difference made after running: cmake --build . --parallel

After running: ... [ 99%] Built target t12_default_ports [ 99%] Built target t06_subtree_port_remapping [100%] Linking CXX executable t11_groot_howto [100%] Linking CXX executable ex03_sqlite_log [100%] Built target t11_groot_howto [100%] Built target ex03_sqlite_log [100%] Linking CXX executable behaviortree_cpp_test [100%] Built target behaviortree_cpp_test

But build folder does not contain any lib or dll etc. image

Did something go wrong? Running with administrative privileges did not make a difference.

jerylteo commented 1 month ago

Installing with Pixi works but program crashes because "libzmq-mt-4_3_5.dll was not found".

I've literally tried all ways I can think of to build this.

Would appreciate some help.

jerylteo commented 1 month ago

Building with OSX replicates the issue.

I think the build works, but there could be some configuration that does not build a dll/lib for non-Windows OS. Unfortunately, I need to add this to a Windows VS Project, so I do need to be able to link the library over.

Looks like I've made one full circle and need to build in Windows, but that doesn't work. #867

jerylteo commented 1 month ago

Building it directly with VS fails to build the library with zmq and sqlite3 errors:

2>------ Build started: Project: behaviortree_cpp, Configuration: Debug x64 ------ 2>Auto build dll exports 2> Creating library C:/Users/jeryl/Documents/GitHub/build2/Debug/behaviortree_cppd.lib and object C:/Users/jeryl/Documents/GitHub/build2/Debug/behaviortree_cppd.exp 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_errno referenced in function "public: cdecl zmq::error_t::error_t(void)" (??0error_t@zmq@@QEAA@XZ) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_strerror referenced in function "public: virtual char const * cdecl zmq::error_t::what(void)const " (?what@error_t@zmq@@UEBAPEBDXZ) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_ctx_new referenced in function "public: cdecl zmq::context_t::context_t(void)" (??0context_t@zmq@@QEAA@XZ) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_ctx_term referenced in function "public: void cdecl zmq::context_t::close(void)" (?close@context_t@zmq@@QEAAXXZ) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_msg_init referenced in function "public: __cdecl zmq::message_t::message_t(class zmq::message_t &&)" (??0message_t@zmq@@QEAA@$$QEAV01@@Z) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_msg_init_size referenced in function "public: cdecl zmq::message_t::message_t(void const *,unsigned int64)" (??0message_t@zmq@@QEAA@PEBX_K@Z) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_msg_send referenced in function "public: class std::optional cdecl zmq::detail::socket_base::send(class zmq::message_t &,enum zmq::send_flags)" (?send@socket_base@detail@zmq@@QEAA?AV?$optional@_K@std@@AEAVmessage_t@3@W4send_flags@3@@Z) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_msg_recv referenced in function "public: class std::optional<unsigned int64> cdecl zmq::detail::socket_base::recv(class zmq::message_t &,enum zmq::recv_flags)" (?recv@socket_base@detail@zmq@@QEAA?AV?$optional@_K@std@@AEAVmessage_t@3@W4recv_flags@3@@Z) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_msg_close referenced in function "public: cdecl zmq::message_t::~message_t(void)" (??1message_t@zmq@@QEAA@XZ) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_msg_data referenced in function "public: void cdecl zmq::message_t::data(void)" (?data@message_t@zmq@@QEAAPEAXXZ) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol __imp_zmq_msg_size referenced in function "public: unsigned int64 cdecl zmq::message_t::size(void)const " (?size@message_t@zmq@@QEBA_KXZ) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_msg_more referenced in function "public: bool cdecl zmq::message_t::more(void)const " (?more@message_t@zmq@@QEBA_NXZ) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_socket referenced in function "public: cdecl zmq::socket_t::socket_t(class zmq::context_t &,int)" (??0socket_t@zmq@@QEAA@AEAVcontext_t@1@H@Z) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_close referenced in function "public: void __cdecl zmq::socket_t::close(void)" (?close@socket_t@zmq@@QEAAXXZ) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_setsockopt referenced in function "private: void cdecl zmq::detail::socket_base::set_option(int,void const ,unsigned int64)" (?set_option@socket_base@detail@zmq@@AEAAXHPEBX_K@Z) 2>groot2_publisher.obj : error LNK2019: unresolved external symbol imp_zmq_bind referenced in function "public: void cdecl zmq::detail::socket_base::bind(char const *)" (?bind@socket_base@detail@zmq@@QEAAXPEBD@Z) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_close referenced in function "public: bool cdecl sqlite::Connection::Close(void)" (?Close@Connection@sqlite@@QEAA_NXZ) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_open referenced in function "public: bool cdecl sqlite::Connection::Open(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?Open@Connection@sqlite@@QEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_extended_errcode referenced in function "bool cdecl sqlite::Priv::CheckError(struct sqlite3 ,int)" (?CheckError@Priv@sqlite@@YA_NPEAUsqlite3@@H@Z) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_errmsg referenced in function "bool __cdecl sqlite::Priv::CheckError(struct sqlite3 ,int)" (?CheckError@Priv@sqlite@@YA_NPEAUsqlite3@@H@Z) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_errstr referenced in function "bool cdecl sqlite::Priv::CheckError(int)" (?CheckError@Priv@sqlite@@YA_NH@Z) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_prepare_v2 referenced in function "public: cdecl sqlite::Priv::Statement::Statement(class sqlite::Connection &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (??0Statement@Priv@sqlite@@QEAA@AEAVConnection@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_bind_int referenced in function "void cdecl sqlite::Priv::Append(struct sqlite3_stmt ,int,int const &)" (?Append@Priv@sqlite@@YAXPEAUsqlite3_stmt@@HAEBH@Z) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_bind_int64 referenced in function "void __cdecl sqlite::Priv::Append(struct sqlite3_stmt ,int,int64 const &)" (?Append@Priv@sqlite@@YAXPEAUsqlite3_stmt@@HAEB_J@Z) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_bind_text referenced in function "void cdecl sqlite::Priv::Append(struct sqlite3_stmt *,int,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?Append@Priv@sqlite@@YAXPEAUsqlite3_stmt@@HAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_step referenced in function "public: bool __cdecl sqlite::Priv::Statement::Advance(void)const " (?Advance@Statement@Priv@sqlite@@QEBA_NXZ) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_column_int referenced in function "public: int cdecl sqlite::Priv::Statement::Get(int)const " (??$Get@H@Statement@Priv@sqlite@@QEBAHH@Z) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_finalize referenced in function "public: cdecl sqlite::Priv::Statement::~Statement(void)" (??1Statement@Priv@sqlite@@QEAA@XZ) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_reset referenced in function "public: bool __cdecl sqlite::Priv::Statement::Reset(void)const " (?Reset@Statement@Priv@sqlite@@QEBA_NXZ) 2>bt_sqlite_logger.obj : error LNK2019: unresolved external symbol sqlite3_db_cacheflush referenced in function "public: virtual void cdecl BT::SqliteLogger::flush(void)" (?flush@SqliteLogger@BT@@UEAAXXZ) 2>C:\Users\jeryl\Documents\GitHub\build2\Debug\behaviortree_cppd.dll : fatal error LNK1120: 30 unresolved externals 2>Done building project "behaviortree_cpp.vcxproj" -- FAILED.

jerylteo commented 1 month ago

Removing ZMQ and SQLite3 from CMakeList allows the library to build properly.

However, when running a sample program on Debug mode, I get a Read Access Violation error from behaviortree_cppd.dll. Release mode works, but I need to be able to run in Debug mode. This error should be another topic. #869

tony-p commented 1 month ago

Are you building with ROS2 by any chance? if so I have been adding https://github.com/tony-p/BehaviorTree.CPP/blob/e923c1fc412e2775cf1b5dbeae77cf7fd78525f0/cmake/ament_build.cmake#L7 for the pixi build to work.

Can't remember exactly why I haven't upstreamed it, either it broke the regular build or I thought it was just too hacky

On WSL/Linux with pixi/robostack I ended up manually linking the libraries https://github.com/RoboStack/ros-humble/issues/119

Not sure if this actually still an issue with behaviortree.CPP ZMQ as I believe the libraries are now linked as Public, but definitely had to do that in the past

tony-p commented 1 month ago

when you run with pixi, are you running it within the pixi environement?

pixi is built for a flavour of a conda virtual environment, so to run you should either use pixi shell to enter the pixi environment, or prefix your execution command with pixi run https://pixi.sh