Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Allan_H_
Beginner
154 Views

How to properly link libembree.so to ispc program?

Jump to solution

Hi,

I'm having difficulties working with Embree on an ispc program. For example, I created the following program:

#include <embree2/rtcore.isph>

export void bar()
{
  rtcInit();
}

And compiled with:

$ ispc -I/usr/local/include -o ispc/bar_ispc.o -h ispc/bar_ispc.h ispc/bar.ispc
$ clang -I./ -L/usr/local/lib -lembree ispc/bar_ispc.o main.cpp -v -o ${EXE}

This results in: ispc/bar.ispc:(.text+0x3): undefined reference to `rtcInit___un_3C_Cunt_3E_'

"rtcInit()" is implemented in "kernels/common/rtcore_ispc.ispc", so I attempted to compile the file and link statically. The problem is now that all the "ispc*()" methods, like "ispcInit()", are not visible (see below), which makes me think that is not the right way of doing this. The Embree build system explicitly compiles the "rtcore_ispc.ispc" file with "-fvisibility=hidden".

hase@kuroi:/usr/local/lib$ readelf -s libembree.so | grep ispcInit
  5412: 000000000001e690     5 FUNC    LOCAL  DEFAULT   12 ispcInit

 

So, what should I do to use Embree inside my ispc program? I was looking into how the Tutorials manage to solve this problem, but if I choose to replicate their build system, I would need to ship the Embree source code with my code, right?

Thank you.

0 Kudos
1 Solution
SvenW_Intel
Moderator
154 Views

The problem is that the libembree.so is compiled with the multi-target mode of ISPC, which generates different symbol names. You also have to enable multiple targets in your ISPC application to make the linking work, e.g. by adding --target sse2,sse4,avx,avx2 to your ISPC command line. 

View solution in original post

3 Replies
Allan_H_
Beginner
154 Views

Just a small correction. When I said "The Embree build system explicitly compiles the "rtcore_ispc.ispc" file with "-fvisibility=hidden".", I meant: "The Embree build system explicitly compiles the "rtcore_ispc.cpp" file with "-fvisibility=hidden". The "rtcore_ispc.cpp" file is the file with the "ispc*()" functions implementations.

SvenW_Intel
Moderator
155 Views

The problem is that the libembree.so is compiled with the multi-target mode of ISPC, which generates different symbol names. You also have to enable multiple targets in your ISPC application to make the linking work, e.g. by adding --target sse2,sse4,avx,avx2 to your ISPC command line. 

View solution in original post

Allan_H_
Beginner
154 Views

Thank for your fast answer. I didn't know about this feature of the ISPC compiler. By using multi-target mode on my ispc program I managed to make it work properly with Embree.

 

For anyone also facing this problem, you can read a bit more about ISPC's multi-target mode on: http://ispc.github.io/faq.html#how-can-i-generate-a-single-binary-executable-with-support-for-multip...

Reply