Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while building simple pub/sub project from examples #242

Closed
nullbyto opened this issue Oct 5, 2024 · 1 comment · Fixed by #241
Closed

Error while building simple pub/sub project from examples #242

nullbyto opened this issue Oct 5, 2024 · 1 comment · Fixed by #241
Labels
bug Something isn't working

Comments

@nullbyto
Copy link

nullbyto commented Oct 5, 2024

Describe the bug

Hello, I am new to Zenoh, I am trying to build a simple publisher/subscriber program (taken from docs: https://zenoh-cpp.readthedocs.io/en/latest/pubsub.html) for testing, when building i get this error:

[ 25%] Building CXX object CMakeFiles/pubs.dir/publisher.cpp.o
In file included from /usr/local/include/zenoh/api/bytes.hxx:18,
                 from /usr/local/include/zenoh/api.hxx:16,
                 from /usr/local/include/zenoh.hxx:15,
                 from /home/amin/code/zenoh/publisher.cpp:1:
/usr/local/include/zenoh/api/session.hxx: In member function ‘void zenoh::Session::close(zenoh::Session::SessionCloseOptions&&, zenoh::ZResult*) &&’:
/usr/local/include/zenoh/api/session.hxx:890:9: error: cannot convert ‘z_moved_session_t*’ to ‘z_loaned_session_t*’
  890 |         __ZENOH_RESULT_CHECK(::z_close(interop::as_moved_c_ptr(*this), nullptr), err, "Failed to close the session");
      |         ^~~~~~~~~~~~~~~~~~~~
      |         |
      |         z_moved_session_t*
In file included from /usr/local/include/zenoh.h:35,
                 from /usr/local/include/zenoh/zenohc.hxx:14,
                 from /usr/local/include/zenoh/api/base.hxx:21,
                 from /usr/local/include/zenoh/api/bytes.hxx:18,
                 from /usr/local/include/zenoh/api.hxx:16,
                 from /usr/local/include/zenoh.hxx:15,
                 from /home/amin/code/zenoh/publisher.cpp:1:
/usr/local/include/zenoh_commons.h:1724:47: note:   initializing argument 1 of ‘z_result_t z_close(z_loaned_session_t*, const z_close_options_t*)’
 1724 | z_result_t z_close(struct z_loaned_session_t *session,
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/local/include/zenoh/api/bytes.hxx:18,
                 from /usr/local/include/zenoh/api.hxx:16,
                 from /usr/local/include/zenoh.hxx:15,
                 from /home/amin/code/zenoh/publisher.cpp:1:
/usr/local/include/zenoh/api/session.hxx:890:9: error: cannot convert ‘z_moved_session_t*’ to ‘z_loaned_session_t*’
  890 |         __ZENOH_RESULT_CHECK(::z_close(interop::as_moved_c_ptr(*this), nullptr), err, "Failed to close the session");
      |         ^~~~~~~~~~~~~~~~~~~~
      |         |
      |         z_moved_session_t*
In file included from /usr/local/include/zenoh.h:35,
                 from /usr/local/include/zenoh/zenohc.hxx:14,
                 from /usr/local/include/zenoh/api/base.hxx:21,
                 from /usr/local/include/zenoh/api/bytes.hxx:18,
                 from /usr/local/include/zenoh/api.hxx:16,
                 from /usr/local/include/zenoh.hxx:15,
                 from /home/amin/code/zenoh/publisher.cpp:1:
/usr/local/include/zenoh_commons.h:1724:47: note:   initializing argument 1 of ‘z_result_t z_close(z_loaned_session_t*, const z_close_options_t*)’
 1724 | z_result_t z_close(struct z_loaned_session_t *session,
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/home/amin/code/zenoh/publisher.cpp: In function ‘int main(int, char**)’:
/home/amin/code/zenoh/publisher.cpp:8:55: error: ‘serialize’ is not a member of ‘zenoh::Bytes’
    8 |    session.put(KeyExpr("demo/example/simple"), Bytes::serialize("Simple!"));
      |                                                       ^~~~~~~~~
gmake[2]: *** [CMakeFiles/pubs.dir/build.make:76: CMakeFiles/pubs.dir/publisher.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:117: CMakeFiles/pubs.dir/all] Error 2
gmake: *** [Makefile:111: all] Error 2

I get the same error while trying to build the zenoh-cpp examples.

To reproduce

After i built zenoh-c and zenoh-cpp.

In test project with publisher.cpp and subscriber.cpp, I do:

mkdir -p build && cd build
cmake ..
make

I get the error after running make.

CMakeLists.txt:

project(test-zenoh)

cmake_minimum_required(VERSION 3.16)

if(CMAKE_BUILD_TYPE STREQUAL "")
    set(CMAKE_BUILD_TYPE Release)
endif()

find_package(zenohc REQUIRED)
find_package(zenohcxx REQUIRED)

# for both publisher and subscriber
add_executable(pubs publisher.cpp)
add_executable(subs subscriber.cpp)

target_link_libraries(pubs PUBLIC
    zenohcxx::zenohc
)
target_link_libraries(subs PUBLIC
    zenohcxx::zenohc
)
set_property(TARGET pubs PROPERTY LANGUAGE CXX)
set_property(TARGET pubs PROPERTY CXX_STANDARD 17)
set_property(TARGET subs PROPERTY LANGUAGE CXX)
set_property(TARGET subs PROPERTY CXX_STANDARD 17)

System info

@nullbyto nullbyto added the bug Something isn't working label Oct 5, 2024
@DenisBiryukov91
Copy link
Contributor

Hello, sorry there is a small lag between updating zenoh-c and zenoh-cpp versions, #241 should resolve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants