Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
595 Discussions

Intel oneAPI Compiler is failing to export DLL functions when sqrt() is called

arctic_circle
Beginner
492 Views

I'm using the Intel C++ 2024 Compiler in Visual Studio to make a DLL. I'm not encountering any compiler errors, but if I call sqrt() anywhere, the DLL silently fails when called by other programs. In other words, calling sqrt() is somehow stopping the function names from being exported properly (maybe interfering with the symbols, I'm not sure).

The problem is easy to reproduce. The following code will compile into a DLL using oneAPI in Visual Studio but you won't be able to call any of its exported functions from other programs. If you comment out the line with sqrt(), then the DLL will work properly:

 

#include <cmath>
#define EXPORT extern "C" __declspec(dllexport)

float some_function(float num) {
    num = std::sqrt(num); //comment this out and the DLL works
    return num; 
}

EXPORT int this_should_return_4_but_it_doesnt() {
    return 4;
}

 

Note that it's not just the function that calls sqrt() that will fail; every external function that the DLL should be exporting stops working, even functions that don't call sqrt().

Note that MSVC and GCC do not have this problem. They will compile the same code into a DLL and export functions without issues.

oneAPI can produce very efficient code (often better than MSVC and GCC) and I'd like to use it for DLLs but the inability to call sqrt() is extremely limiting.

Can you please let me know how to fix this problem?

0 Kudos
3 Replies
Alex_Y_Intel
Moderator
357 Views

Your issue has been escalated to our engineers and we'll work on it internally and reply you the update when we have a solution. 

0 Kudos
cw_intel
Moderator
271 Views

Hi,

I tested the code with Intel C++ compiler 2024.1 version, but I didn't find the problem you described. The dll also works fine when calling sqrt().

Can you tell us the version of compiler? If you use 2024.0 version, please try using the latest 2024.1 version. If you use 2024.1 version and have the same problem, please provide us with the complete test program, as well as your compilation commands.

Thanks.


0 Kudos
cw_intel
Moderator
158 Views

We haven't heard back from you for a long time so we are assuming that you have have found a solution on your own. If you need any additional assistance. please start a new thread.

0 Kudos
Reply