Why doesn't -static-intel pull in a definition for __intel_sse2_strdup?

Why doesn't -static-intel pull in a definition for __intel_sse2_strdup?


I am using "icc (ICC) 12.1.5 20120612"
I have three very simple files:

char *duplicate(char const *str);

#include "header.h"

char *

duplicate(char const *str)


   if ( str == NULL )

      return NULL;


      return strdup (str);



#include "header.h"


main(int argc, char **argv)


   int i;

   for (i = 0; i < argc; ++i) {

      char *s = duplicate(argv[i]);

      printf("%sn", s);



   return 0;

I compile object.c using icc into a shared object with
icc -vec-report0 -O -fPIC -fno-strict-aliasing -Wall -w1 -Wcheck -c -o object.o object.c

icc -o libobject.so object.o -shared -static-intel
Then I compile main.c into a binary using gcc:
gcc -o main -L. -lobject main.c
What I get by the last command is 'undefined reference to __intel_sse2_strdup'.
I found that this function is defined by libintlc and libirc but neither adding '-lintlc' nor adding '-lirc' to the command that creates the shared object did fix the problem.

I have created and attached a shell script that reproduces the above build steps and also produces a more verbose output when creating the shared object. The output of that script is (ICCDIR is the directory in which I have installed icc)

icc (ICC) 12.1.5 20120612

Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.







    "-mGLOB_options_string=-o libobject.so -shared -static-intel -#" 






















    "-mIPOPT_link_version= 20051219 (SUSE Linux)" 

    "-mIPOPT_cmdline_link="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crti.o" "/usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbeginS.o" "--eh-frame-hdr" "-shared" "-o" "libobject.so" "-LICCDIR/Linux-i686/12.1/composer_xe_2011_sp1.11.339/compiler/lib/intel64" "-L/usr/lib64/gcc/x86_64-suse-linux/4.1.2" "-L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64" "-L/lib/../lib64" "-L/usr/lib/../lib64" "-L/lib64" "-L." "-L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib" "-L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.." "-L/lib" "-L/usr/lib64" "-L/usr/lib" "object.o" "-Bstatic" "-limf" "-lsvml" "-Bdynamic" "-lm" "-Bstatic" "-lipgo" "-ldecimal" "-Bdynamic" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc" "-Bdynamic" "-lc" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc_s" "-Bdynamic" "-ldl" "-lc" "/usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtendS.o" "/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o"" 




    "-mGLOB_linker_version= 20051219 (SUSE Linux)" 
























































rm /tmp/iccA2qDStlibgcc
rm /tmp/iccmpJDJNgnudirs
rm /tmp/iccs0aXsrolis
rm /tmp/iccaF1CkLalis
rm /tmp/iccc8qjc5elis
rm /tmp/iccilOHVIllis
rm /tmp/icc6CLpN2slis
rm /tmp/iccGjh8Emscript
rm /tmp/ipo_iccut2hB7.o
rm /tmp/icc4B1RwGgas
rm /tmp/iccEAcip0as_.s
rm /tmp/iccMi6Jhkldashv
rm /tmp/icceLmgbEgnudirs
rm /tmp/iccg4ur5Xldashv
rm /tmp/iccAktE0hldashv
rm /tmp/iccU421WBarg
                 U __intel_sse2_strdup

./libobject.so: undefined reference to `__intel_sse2_strdup'

collect2: ld returned 1 exit status
My understanding of the '-static-intel' option was that it would pull in
all intel-specific functions but that does not seem to be true? What do
I need to do to get a definition of this function into the shared



Downloadtext/x-sh build.sh920 bytes
4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Daniel,
Option "-static-intel" causes Intel-provided libraries to be linked in statically. But i didnt face any errors whileperforming the same steps asyou did.

shv@dpd20:~/quad/t106905> icc -V

Intel C Intel 64 Compiler XE for applications running on Intel 64, Version Build 20120612

Copyright (C) 1985-2012 Intel Corporation. All rights reserved.

shv@dpd20:~/quad/t106905> icc -vec-report0 -O -fPIC -fno-strict-aliasing -Wall -w1 -Wcheck -c -o object.o object.c
shv@dpd20:~/quad/t106905> icc -o libobject.so object.o -shared -static-intel
shv@dpd20:~/quad/t106905> gcc -o main -L. -lobject main.c
shv@dpd20:~/quad/t106905> ./main sukruth

As we can see i am getting the expected output. The only thing i did extra from the steps you have mentioned is to just include the libobject.so library :- "export LD_LIBRARY_PATH=/home/cmplr/usr4/shv/quad/t106905:$LD_LIBRARY_PATH". where t106905 is the folder which contain header.h, object.c, main.c and libobject.so. Please feel free to let me know if i had missed some steps.

Sukruth H.V

Thanks for your reply.
In my initial experiment LD_LIBRARY_PATH was blank. But even setting it to the directory that contains the shared object does not fix the linker problem for me. I checked that I use the exact same version of icc like you (
Could you run 'nm libobject.so | grep strdup'? For me this gives

U __intel_sse2_strdup
indicating that the symbol is not defined.



Hello Daniel,

in your script you used the option "-#", which is an alias to "-dryrun". Hence, it won't create the SO "libobject.so".
The undefined symbol you're seeing must come from an earlier (manual) run.

I'm agreeing to Sukruth that with and the options you provided (omitting "-#") it works. And it has to work because references to Intel libraries are already resolved ("-static-intel").

Best regards,

Georg Zitzlsberger

Leave a Comment

Please sign in to add a comment. Not a member? Join today