Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

error LNK2019: unresolved external symbol __floorf referenced in function main after updating VS2019

mikeitexpert
New Contributor II
3,863 Views

I was able to build my app using icl and MSVC2019 up until recently. I did upgrade/update by accident to MSVC 14.28.29910 and started getting the below error right after the update... below is the sample you could use to reproduce the error along with command line options I use ...

 

 

#include <cstdlib>
#include <cstdio>
#include <cmath>

int main(){
    printf("a = %f \n", floor(3.4f));
    return 0;
}

 

 

 

interestingly enough, same code is compiled and executes fine using MinGW GCC compiler, not the case for ICL though. below you can find the error message.

 

 

 

C:\Users\Mike-laptop\sample>gcc tmp\test.cpp

C:\Users\Mike-laptop\sample>a.exe
a = 3.000000

C:\Users\Mike-laptop\sample>icl tmp\test.cpp
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.2.254 Build 20200623
Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.

test.cpp
Microsoft (R) Incremental Linker Version 14.28.29913.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:test.exe
test.obj
test.obj : error LNK2019: unresolved external symbol __floorf referenced in function main
test.exe : fatal error LNK1120: 1 unresolved externals

C:\Users\Mike-laptop\sample>

 

 

 

0 Kudos
12 Replies
GouthamK_Intel
Moderator
3,833 Views

Hi Mike,

We are able to reproduce the error on our end, we are working on your issue internally and we will get back to you soon.

Meanwhile, could you please try floorf instead of floor in your code and let us know if your issue persists.

printf("a = %f \n", floor(3.4f));

to

printf("a = %f \n",floorf(3.4f));

 

Regards

Goutham

 

0 Kudos
GouthamK_Intel
Moderator
3,780 Views

Hi Mike,

Could you please let us know whether the above-mentioned workaround helped or not?

Also, let us know the Intel Product version(Intel Parallel Studio XE / Intel oneAPI Toolkits) which you are currently using?


Regards

Goutham


0 Kudos
mikeitexpert
New Contributor II
3,765 Views

Yes that partly worked around the problem ...

however, I need to know what is the viable solution when floor's argument is a C++ template variable. 

For now, I just had to change the variable types to flout variables (as opposed to template variables).

I currently use "ICL 19.1.2.254 Build 20200623" as part of Intel System Studio.

 

I am planning to upgrade to oneAPI HPC in near future.  I am not sure if it is a good upgrade though. Maybe you can elaborate further please ???

 

 

 

0 Kudos
GouthamK_Intel
Moderator
3,738 Views

Hi Mike,

>>"I currently use "ICL 19.1.2.254 Build 20200623" as part of Intel System Studio."

We can see that you are currently using an older version of the Intel compiler which is not compatible with the latest version of Visual Studio. Either you can downgrade the Visual Studio to the supported version or upgrade the Intel compiler.

Please find the details of Intel® Compilers Compatibility with Microsoft Visual Studio* and Xcode*.

https://software.intel.com/content/www/us/en/develop/articles/intel-compilers-compatibility-with-microsoft-visual-studio-and-xcode.html


>>"I am planning to upgrade to oneAPI HPC in near future. I am not sure if it is a good upgrade though. Maybe you can elaborate further please ???"

Currently, as you are using an older version of the Intel compiler, we recommend you to upgrade to Intel oneAPI to get the latest Intel compilers along with new additional features.

We can see that you are an Intel® System Studio User, so you can install Intel® oneAPI Base & IoT Toolkit which is equivalent to Intel System Studio. Please find the below link for more detail regarding the same.

https://software.intel.com/content/www/us/en/develop/tools/oneapi/commercial-base-iot.html#linklist_1519377622__248621770

Please let us know if this helps. Have a Good day.


Thanks & Regards

Goutham


0 Kudos
Mentzer__Stuart
3,721 Views

Sadly this problem is still present with oneAPI 2021.2 icl and Visual C++ 19.28.29913 (VS 16.9.3).

0 Kudos
GouthamK_Intel
Moderator
3,668 Views

Hi

I apologize for the delay.

>>" error LNK2019: unresolved external symbol __floorf referenced in function main."

The above issue is resolved in the new oneAPI update, i.e., Intel oneAPI 2021.2 version. We have checked on our end, and we can successfully compile and run the code.

Our Environment details:

Compiler Versions:

  1. C:\Program Files (x86)\Intel\oneAPI>dpcpp -v >>Intel(R) oneAPI DPC++ Compiler 2021.2.0 (2021.2.0.20210317)
  2. C:\Program Files (x86)\Intel\oneAPI>icl -v >>Intel(R) C++ Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_0000 

Visual Studio Version: VS 2019 16.9.4

OS Version: Windows 10

Could you please try recompiling and running the code after updating it? If your issue persists, please share your environment details along with the compiler versions and error logs.


Thanks & Regards

Goutham


0 Kudos
Mentzer__Stuart
3,660 Views

The attached code gives me this error with the exact same Intel C++ and Visual C++ versions you list on Windows 10 20H2.

0 Kudos
Frank_R_1
Beginner
3,635 Views

Hi,

C:\Program Files (x86)\Intel\oneAPI>icl -v >>Intel(R) C++ Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_0000

don't work on these new cmath headers!

 

0 Kudos
Viet_H_Intel
Moderator
3,494 Views

This issue is only seen with later VS2019 versions (e.g. 16.9.3, 16.9.4...).

Please use one of the current supported VS2019 listed https://software.intel.com/content/www/us/en/develop/articles/intel-compilers-compatibility-with-microsoft-visual-studio-and-xcode.html


Thanks,


0 Kudos
Viet_H_Intel
Moderator
2,712 Views

This problem seems to be fixed in ICL2021.5 in oneAPI 2022.1.2 HPC toolkit.

Can you please try it out and let us know so that we can close this case.

Thanks,


0 Kudos
Mentzer__Stuart
2,699 Views

Not the OP but I can confirm that this problem appears to be fixed in ICL 2021.5 (at least with cl 19.30.30706 from VS2022 17.0.4).

0 Kudos
Viet_H_Intel
Moderator
2,688 Views

Thanks for your confirmation. Let's close this thread. If you have any other questions/concerns please create a new one.


Regards,

Viet


0 Kudos
Reply