RenderKit / embree

Embree ray tracing kernels repository.
Apache License 2.0
2.36k stars 385 forks source link

libembree.a vs. libembree.so.2 #130

Closed nastronaut closed 7 years ago

nastronaut commented 7 years ago

Hello, I would like to build an application using icpc where the application links to embree. The dynamically-linked executable works fine. When I substitute the statically linked libembree.a for the corresponding shared object, I get complaints from the linker:

/u/pmoran/local/lib64/libembree.a(device.cpp.o): In function embree::Device::exitTaskingSystem()': device.cpp:(.text+0x2ec0): undefined reference toembree::TaskScheduler::destroy()' device.cpp:(.text+0x2f13): undefined reference to embree::TaskScheduler::create(unsigned long, bool, bool)' /u/pmoran/local/lib64/libembree.a(device.cpp.o): In functionembree::Device::initTaskingSystem(unsigned long)': device.cpp:(.text+0x33b4): undefined reference to `embree::TaskScheduler::create(unsigned long, bool, bool)'

I'd appreciate some help figuring out why use of the static and dynamic versions of libembree lead to different results.

Thanks,

Pat

svenwoop commented 7 years ago

You enabled the internal tasking system but did not link statically against it. Please link against libsys.a, libsimd.a, libtasking.a libembree2.a libembree_sse42.a libembree_avx.a and libembree_avx2.a.

nastronaut commented 7 years ago

Thanks. I had most of the libraries you suggested in my link; it was libtasking.a that was missing. With respect to the tasking system, I did not make an explicit choice in the initial arguments I provided to cmake. Here is what embree reports during a run in verbose mode:

Tasking : TBB4.4 TBB_header_interface_9003 TBB_lib_interface_9003

By the way, I noticed that "make install" does not install the supporting .a libraries, I issued an install command for them manually. I'm guessing embree does not get built in static libraries mode very often.

Thanks again for your help.

johguenther commented 7 years ago

FYI, we though of merging all the libXXX.a into a single library (when building static libs) to make linking of applications more convenient. However, there seems to be not easy, platform-independent way doing this. The best solution I found is implemented in MySQL's libutils.cmake.

svenwoop commented 7 years ago

We could use CMake object libraries instead of static libraries internally, and link all object libraries into one static library (https://cmake.org/cmake/help/v3.5/command/add_library.html#object-libraries).

chuckatkins commented 7 years ago

This is indeed an ideal scenario for object libraries. Given that it would bump the CMake requirement from 2.8.11 to something fairly modern, I'd be willing to take a pass at 1) implementing the use of object libraries instead of multiple individual ISA libs, and then 2) modernizing the CMake code as a whole, if this is something you'd all be willing to consider.

johguenther commented 7 years ago

Modernizing the CMake code is also on our wishlist, e.g. exporting targets instead of setting LIBRARY variables in embree-config.

jkammerl commented 6 years ago

I'm running into the same missing symbols issue during static linking. I understand that linking to "libsys.a, libsimd.a, libtasking.a libembree2.a libembree_sse42.a libembree_avx.a and libembree_avx2.a" would solve it, however libembree.a is the only library that's exported via an install target. Could you add the other libraries as well to the CMake's installation configuration or merge all symbols into libembree.a?

svenwoop commented 6 years ago

Added a fix to the v2.17.3-alpha.1 branch that installs all static libraries when EMBREE_STATIC_LIB=ON. Could you please check if this tag fits your needs.