- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I try to compile my code with the '-fast' option, I always get an error
$ icc -fast test.c
ld: cannot find -lm
The processor of my host is Intel® Xeon® Processor E7-4860. I also tested this option on some other types of processors and had no such problem. Please help.
Ping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ping,
Basically the "-fast" option is equal to combination of these options :- "-ipo –O3 -no-prec-div -static -xHost" , So -xHost will generate instructions for the highest instruction set available on the compilation host processor. As Tim pointed out, on E5-2670 v2 where AVX is enabled, compiler may choose AVX optimization.
Being said that, one of the reason for the error "ld: cannot find -lm" would be the static linking of libraries, So you may either download the static version of the libraries or you may consider not to use -static option that is part of the fast and rather you can individually provide "-ipo –O3 -no-prec-div -xHost
" options.
Please refer to this article :- https://software.intel.com/en-us/articles/error-ld-cannot-find-lm/
Hope this helps!
Regards,
Sukruth H V
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you install g++ development system and keep it on path?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. Actually, I am testing this on a cluster with mixed types of nodes. The compiler is installed on a shared file system. The '-fast' option works on Intel® Xeon® Processor E5-2670 v2, but not on Intel® Xeon® Processor E5-2670 v2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fast selects architecture of build cpu.
set eg
-mavx to run on early avx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tim,
What are the exact flags should I put? Why -fast won't work?
Thanks,
Ping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you build with -fast on a CPU such as E5-2670 v2 which has AVX, your build will not run on a CPU such as E7-4860 which doesn't support AVX. Setting -msse4.1 would make the build compatible with such CPUs. I don't know whether architecture settings are well tested along with -ffast, so you might consider a more specific set of options.
If you want a build where the compiler decides whether to make code paths for both AVX and SSE4, with run-time branch select, there are option combinations such as -axAVX -msse4.1
As mentioned before, the libm is provided by an installation of g++. Under a supported linux distro, or any similar ones, simply having installed g++ development package for the same (32- or 64-bit) mode which you are using would take care of it. It's possible, if icc was installed in the absence of gcc prerequisites, icc may need to be removed by its own uninstall script and then installed again after correcting the problem with g++.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ping,
Basically the "-fast" option is equal to combination of these options :- "-ipo –O3 -no-prec-div -static -xHost" , So -xHost will generate instructions for the highest instruction set available on the compilation host processor. As Tim pointed out, on E5-2670 v2 where AVX is enabled, compiler may choose AVX optimization.
Being said that, one of the reason for the error "ld: cannot find -lm" would be the static linking of libraries, So you may either download the static version of the libraries or you may consider not to use -static option that is part of the fast and rather you can individually provide "-ipo –O3 -no-prec-div -xHost
" options.
Please refer to this article :- https://software.intel.com/en-us/articles/error-ld-cannot-find-lm/
Hope this helps!
Regards,
Sukruth H V
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, just as Tim said, E7-4680 only support up to the sse4.2 instruction set.
Also, as to 'The '-fast' option works on Intel® Xeon® Processor E5-2670 v2, but not on Intel® Xeon® Processor E5-2670 v2.'
Here you means you are using the compiler to build the binary on E5-2670 v2, and then test the same binary on E7-4680, right? Then that's the problem
Thank you.
--
QIAOMIN.Q
Intel Developer Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Qiaomin,
No. I was building the binary on E7 and was wandering why '-fast' returns the error "ld: cannot find -lm".
Ping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ping wrote:
Qiaomin,
No. I was building the binary on E7 and was wandering why '-fast' returns the error "ld: cannot find -lm".
Ping
Then you are likely running into the problem that the static math library wasn't installed on that box, as it's not a default part of recent g++ development system. Further, the libraries needed to support the ia32 (32-bit) compiler on an x86_64 64-bit OS aren't included in the base g++ development system.
It may be easier to choose specific options (as Sukruth mentioned) rather than the -fast collection. One might have thought -fast was intended to get a good score on SPEC benchmark (but perhaps not for general convenience), except that it doesn't include -ansi-alias (until the 15.0 release, where -ansi-alias comes in by default with -O).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tim and Sukruth
I didn't find the static math library on the E7 nodes. This is what I am afraid of: something is inconsistent on our E7 nodes.
Thank you for your help. Now I know why I cannot compile with -fast.
Ping

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page