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

How to avoid linking with libimf.so

dpeterc
Beginner
1,576 Views
My applications are fairly small (one MB or smaller) and most calculations are integer based. Floating point performance is not critical. I need to send updates by e-mail, often to countries with poor connectivity. So I would like to avoid linking to libimf.so, as 2.5 MB (1MB compressed) overhead is fairly big, for a 15% increase of runtime speed I get over gcc.
Is this possible to instruct the icc complier to use the standard math library instead of libimf?
0 Kudos
6 Replies
JenniferJ
Moderator
1,576 Views

Try this:

1. do not use the "mathimf.h" from icc

2. use -nodefaultlibs -llibrary

0 Kudos
dpeterc
Beginner
1,576 Views
Thanks for the hint.
1. I do not include "mathimf.c", but I do "math.h".
2. Tried linking with -nodefaultlibs -limf
but I get the following error on linking:
/usr/lib/gcc/i586-suse-linux/4.1.2/../../../crt1.o: In function `_start':
(.text+0xc): undefined reference to `__libc_csu_fini'
/usr/lib/gcc/i586-suse-linux/4.1.2/../../../crt1.o: In function `_start':
(.text+0x11): undefined reference to `__libc_csu_init'
make: *** [...] Error 1

I am using OpenSuse 10.2, 32 bit, and icc 10.0
Any further help will be greatly appreciated.



0 Kudos
John_O_Intel
Employee
1,576 Views

Hi,

Another suggestion is to use the -static-intel option for the 10.0 compilers (this was -i-static 9.1 & earlier). This will statically link in all of the functions in all Intel provided libraries that your application requires. You can look at the exe size with and without this option to see how much code is being pulled in from libimf, it's possible no code is for you app. Hopefully this will solve your code size issue by avoiding having to redistribute libimf.

When you specify -nodefaultlibs, you need to specify all libraries needed to link, so you would need to pass libc & other libs. You can see which libs are required by running icc -dryrun hello.c - this shows how ld is called. You will need to pass these options to icc (via -Xlinker option), & remove libimf. This is more work, so hopefully statically linking the Intel provide libs solves the problems. Let us know if this works or doesn't, and we can see if there are other ways to solve this.

best regards,

_|ohnO

0 Kudos
dpeterc
Beginner
1,576 Views
-static-intel works like a charm:
only 80 KB overhead on a 1.4 MB binary.
I didn't know that linkers got so smart that they now statically link just what you use, not the whole blob.

Thank you for your help,

Duan Peterc
http://www.arahne.si
0 Kudos
Joseph_A_
Beginner
1,576 Views

How do I statically link libimf using GCC compiler. 

I have a simple program that I want to statically link with Libimf

#include <stdio.h>
#include <math.h>
int main(){
int c=0;
       float k = 6.25;
       float sin_value = powf(2.15,k);
       printf("POW(2.15,6.25) : %f \n", sin_value);
      return 0;
}

gcc powf-example.c -static /pathtointelLibrary/libimf.a

gives the following error

 undefined reference to `__intel_cpu_feature_indicator_x'
libm_feature_flag.c:(.text+0x5a): undefined reference to `__intel_cpu_features_init_x'
libm_feature_flag.c:(.text+0x80): undefined reference to `__intel_cpu_features_init_x'
libm_feature_flag.c:(.text+0xa5): undefined reference to `__intel_cpu_features_init_x'
libm_feature_flag.c:(.text+0xc4): undefined reference to `__intel_cpu_features_init_x'
libm_feature_flag.c:(.text+0xe3): undefined reference to `__intel_cpu_features_init_x'

 

0 Kudos
Alexey_S_Intel2
Employee
1,576 Views

I have the same issue with the static version of libimf:

undefined reference to `__intel_cpu_feature_indicator_x'
libm_feature_flag.c:(.text+0x5a): undefined reference to `__intel_cpu_features_init_x'

But linking against the shared version libimf.so succeeds. Symbols __intel_cpu_feature_indicator_x and __intel_cpu_features_init_x are undefined in both libimf.a and libimf.so. So why it is possible to link against libimf.so, but not possible to link against libimf.a? 

 

0 Kudos
Reply