Unresolved extern function with custom operators on a large class

I have a custom implementation of Int128 for use on Windows as MSVC doesn’t support __int128. I’m using thrust. My implementation works fine when I inline the code, however this approach breaks when I compile multiple objects that use my inlined includes as I get errors that symbols are already defined.

I tried to solve this problem by switching to static-linking, but I’m getting a lot of linker errors that don’t make sense to me. The one I’m hung up on now is:

Unresolved extern function ‘ZplRK8int128_tS1

This demangles to operator+(int128_t const&, int128_t const&). If I remove this function, I get a compiler error that the operator doesn’t exist. If I inline the function in the header file, I get the same “Unresolved extern function” error, which is strange to me, because the implementation is definitely there.

My hunch is that I’m hitting some type of upper-limit on the number of symbols I can export in an object, given the size of the Int128 implementation, but I tried to break up the class and I’m getting similarly odd linker errors about extern functions not being defined.

Am I missing something obvious? Any suggestions on how to chase this down?

I think I’ve found the root cause - my static library isn’t producing device-linkable code.

Trying to track down the best way to set this up in Visual Studio…

I’ve moved all of my files out of my library and into my main project to eliminate any linker errors.

I’m still getting the same error (Unresolved extern function) even though the function is being compiled in the same project.

If you are calling an operator defined in one file (module, compilation unit) from device code in another file (module, compilation unit) then CUDA requires compilation with relocatable device code with device linking. This is not unique or specific to a case involving static libraries (although it may occur there). There are various forum articles that indicate the setting in VS that are needed to request this. Here is an example.

1 Like

Thanks so much! I was indeed overlooking something simple - I had not enabled relocatable device code.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.