GPUOpen-LibrariesAndSDKs / RadeonRays_SDK

Radeon Rays is ray intersection acceleration library for hardware and software multiplatforms using CPU and GPU
MIT License
1.07k stars 192 forks source link

Fails to link to RadeonRays as a static library #177

Open norsetto opened 6 years ago

norsetto commented 6 years ago

If I build radeonrays as a static library and then try to link another program to it, on windows linking fails for all static methods with a message like:

Error LNK2019 unresolved external symbol "declspec(dllimport) public: static void cdecl RadeonRays::IntersectionApi::SetPlatform(enum RadeonRays::DeviceInfo::Platform)" (_imp?SetPlatform@IntersectionApi@RadeonRays@@SAXW4Platform@DeviceInfo@2@@Z)

I believe this is due to radeon_rays.h using the macro RR_STATIC_LIBRARY which in turn define RRAPI as __declspec(dllimport). The easy solution would be to add a #define RR_STATIC_LIBRARY true before including said header in the application.

Is this an intended behavior? If so, should this be somehow documented (can't find anything in README.md )?

Kvalme commented 6 years ago

Yes, this define is needed for static library, but it should be automatically added if you use cmake and just link with RadeonRays target. If you use VS project you can simply add this as global definition instead of adding before header include.