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

Unable to build the sdk (C++) in Windows #610

Open
hirenpatel1207 opened this issue Sep 3, 2024 · 11 comments
Open

Unable to build the sdk (C++) in Windows #610

hirenpatel1207 opened this issue Sep 3, 2024 · 11 comments
Assignees
Labels
question Further information is requested

Comments

@hirenpatel1207
Copy link

hirenpatel1207 commented Sep 3, 2024

Describe your question
Building the sdk from source from C++ throws error in compilation.

Screenshots
Screenshot 2024-09-03 142837

Platform (please complete the following information):

  • OS-1
  • Ouster Firmware Version? [e.g. 2.3, 2.4, ..]
  • C++
  • Windows
  • X64

Goal: Use the C++ sdk to build an application in Windows to capture and store the Lidar data (without using ros2).
I followed the instructions given at https://static.ouster.dev/sdk-docs/cpp/building.html . In the last step it is metioned to open https://github.com/ouster-lidar/ouster-sdk/archive/refs/tags/20240703.zip in Visual studio and build the project. But I am getting errors linkage errors.
Is it possible to get prebuilt binaries for Windows platform?

@hirenpatel1207 hirenpatel1207 added the question Further information is requested label Sep 3, 2024
@Samahu
Copy link
Collaborator

Samahu commented Sep 3, 2024

Hi @hirenpatel1207, can you try to see if this branch helps you build on Windows #608

@matthew-lidar
Copy link
Collaborator

The changes in the PR above were merged into master, so if you use: https://codeload.github.com/ouster-lidar/ouster-sdk/zip/refs/heads/master it should work.

@hirenpatel1207
Copy link
Author

@matthew-lidar I was able to build the master branch. Thanks.
However the build directly generates the example executables.
image
By that way, I would have to import the ouster-sdk source code into my project and then build it together, which is not a great idea for versioning and keeping sdk's seperate.
Is it possible to pre-built the sdk seperately and generate the .h, .lib and .dll s and then use them?

@matthew-lidar
Copy link
Collaborator

matthew-lidar commented Sep 6, 2024

Usually what one would do is build the CMake package, then install it using a command like so run from your build directory:

cmake --install . --config x64-Release

If you used Visual studio, there's probably also a way to trigger this, but I was unable to find documentation saying specifically how.

This will copy the .h .lib and .dll files to a central directory and enable other CMake projects, such as your's to find_package it.

Then do something like the following in your project's CMake and it will automatically find and include those files:

project(your_project)
cmake_minimum_required(VERSION 3.10)

find_package(OusterSDK REQUIRED)

add_executable(your_project main.cpp)
target_link_libraries(your_project OusterSDK::ouster_client)
set_property(TARGET your_project PROPERTY CXX_STANDARD 14)

@hirenpatel1207
Copy link
Author

hirenpatel1207 commented Sep 9, 2024

Do you mean this option in VS?
Screenshot 2024-09-09 120218
install.zip

With that option, I was able to generate the header files and ouster_client.lib, ouster_osf.lib, ouster_pcap.lib, and ouster_viz.lib files (see the attached install.zip folder).
But there are no dlls.
Also I tried to use these header and .lib files in a QT project .pro file but I am getting the following error:
image
I think something related to networking stuff is not getting generated in the install step.

@hirenpatel1207
Copy link
Author

hirenpatel1207 commented Sep 9, 2024

Do you mean this option in VS? Screenshot 2024-09-09 120218 install.zip

With that option, I was able to generate the header files and ouster_client.lib, ouster_osf.lib, ouster_pcap.lib, and ouster_viz.lib files (see the attached install.zip folder). But there are no dlls. Also I tried to use these header and .lib files in a QT project .pro file but I am getting the following error: image I think something related to networking stuff is not getting generated in the install step.

EDIT:
I was able to solve the problem by including "-lws2_32". The build is successfull.
But during runtime, i am getting "write access violation", I think it has something to do with the spdlog.
The program crashes at line-> ouster::sensor::init_logger("info");
Here is the minimalistic example that I am trying:
image

@matthew-lidar
Copy link
Collaborator

matthew-lidar commented Sep 9, 2024

Yeah, that looks to have done it. Currently the SDK is only built statically, so you will not find any .dlls generated, only .libs.

As for the crash, do you have the full stacktrace?

@hirenpatel1207
Copy link
Author

Got it. My "Hello World" sample program runs now. I had linked wrong .libs from vcpkg. Thanks for the help.

@hirenpatel1207
Copy link
Author

hirenpatel1207 commented Sep 11, 2024

Sorry for going back and forth on opening this issue as I was not sure on whether to open a new issue or keep this one.
The build is successfully but the release library version has some problem I think.
For e.g. if i run the client_example.exe of the debug version, it works fine.
But the same client_example.exe of release version does not work.
The method sensor::poll_client(*handle); returns value "0". What does Timed-out state actually mean?

@matthew-lidar
Copy link
Collaborator

On Windows you need to make sure you link debug builds of your program with debug builds of the SDK (and release builds with release builds) for things to work correctly generally. I would check to make sure that is occurring.

Timeout means that no packets were received in the timeout provided to the poll_client function. The default is 1 second.

@hirenpatel1207
Copy link
Author

Yes, I was getting problems with my programs during the release build. Then I had gone back to check if the release version demos work or not. I have tried the demos with no modifications. I had just followed the guide line in the docs to build the package. I had checkout vcpkg 2024.04.26(git checkout 2024.04.26) so that correct libraray versions are linked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants