apollo icon indicating copy to clipboard operation
apollo copied to clipboard

Apollo8.0 add third-party opencl

Open 1121085292 opened this issue 1 year ago • 4 comments

Apollo8.0 add third-party library opencl,i created BUILD file,like this, Screenshot from 2023-10-20 08-32-53 Screenshot from 2023-10-20 08-53-48

then use command “bazel build /path/to/...” build my cpp files , error: no such package '@opencl//': The repository '@opencl' could not be resolved. use command "buildtool build -p /path/" , error: can not find 3rd-opencl-dev.

Screenshot from 2023-10-20 08-36-12

And i used command "bazel build /third-party/opencl/..." to compile successfully. Screenshot from 2023-10-20 08-52-10

I used command "buildtool build -p third-part/" , error: can not find 3rd-opencl-dev. Screenshot from 2023-10-20 08-50-20

Please tell me what should I do?

1121085292 avatar Oct 20 '23 15:10 1121085292

I created the test.cc file in the Apollo root directory to test @opencl. It can be compiled normally. However, after placing the file in a folder in the root directory, the same error is reported, no such package @opencl//

1121085292 avatar Oct 20 '23 16:10 1121085292

what is the content of workspace.bzl?

CesarLiu avatar Oct 23 '23 08:10 CesarLiu

what is the content of workspace.bzl?

"""Load the opencl library"""

Sanitize a dependency so that it works correctly from code that includes

Apollo as a submodule.

def clean_dep(dep): return str(Label(dep))

def repo(): native.new_local_repository( name = "opencl", build_file = clean_dep("//third_party/opencl:opencl.BUILD"), path = "/usr/include", )

1121085292 avatar Oct 23 '23 14:10 1121085292

As it stands, the simplest way to introduce it is to fill in the WORKSPACE file in /apollo_workspace with the following:

load("//third_party/opencl:workspace.bzl", opencl_init = "repo")
opencl_init()

after this, your can directly use buildtool build -p <path> to build your code rather than opencl. since opencl is imported in a 'bazel' way, thus the form '@opencl' is directly recognized by bazel.

WildBeast114514 avatar Nov 15 '23 06:11 WildBeast114514