I am trying to create a static or shared library from a sycl program and use it from a main application build using gcc/g++/clang++. Everything is fine if I use dpcpp to build my main application, but I need to use g++.
For example, my sample sycl_lib.cpp and the main program are as follows.
//sycl_lib.cpp
#include<CL/sycl.hpp>
int func() {
q.submit([&](sycl::handler &h) {
sycl::stream os(1024, 768, h);
h.parallel_for(32, [=](sycl::id<1> i) {
os<<i<<"\n";
});
});
}
//main.cpp
void func();
int main() {
func();
return 0;
}
To create a static library and use it:
dpcpp -c sycl_lib.cpp -fPIC
ar rvs sycl_lib.a sycl_lib.o
dpcpp main.cpp sycl_lib.a
./a.out
This works fine. But I want to use g++ to build main.cpp, it is causing runtime error.
g++ main.cpp sycl_lib.a -L$SYSL_DIR/lib -lsycl
./a.out
which is giving the following error
terminate called after throwing an instance of 'cl::sycl::runtime_error'
what(): No kernel named _ZTSZZ4funcvENKUlRN2cl4sycl7handlerEE6_12clES2_EUlNS0_2idILi1EEEE8_24 was found -46 (CL_INVALID_KERNEL_NAME)
Aborted
Is it possible for an executable created with g++ to use a sycl library created using dpc++?
Thank you