Community
cancel
Showing results for 
Search instead for 
Did you mean: 
djunglas
New Contributor I
107 Views

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

Hi,

I am using "icc (ICC) 12.1.5 20120612"
I have three very simple files:
header.h: [cpp]char *duplicate(char const *str);[/cpp] object.c:[bash]#include #include "header.h" char * duplicate(char const *str) { if ( str == NULL ) return NULL; else return strdup (str); }[/bash] main.c:[bash]#include #include #include "header.h" int main(int argc, char **argv) { int i; for (i = 0; i < argc; ++i) { char *s = duplicate(argv); printf("%s\n", s); free(s); } return 0; }[/bash] I compile object.c using icc into a shared object with
[bash]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[/bash] Then I compile main.c into a binary using gcc:
[bash]gcc -o main -L. -lobject main.c[/bash] 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)
[bash]icc (ICC) 12.1.5 20120612 Copyright (C) 1985-2012 Intel Corporation. All rights reserved. ICCDIR/Linux-i686/12.1/composer_xe_2011_sp1.11.339/bin/intel64/mcpcom \ -mP1OPT_version=12.1-intel64 \ -mGLOB_diag_file=object.diag \ -mP1OPT_print_version=FALSE \ -mCG_use_gas_got_workaround=F \ -mP2OPT_align_option_used=TRUE \ -mGLOB_gcc_version=412 \ "-mGLOB_options_string=-o libobject.so -shared -static-intel -#" \ -mGLOB_cxx_limited_range=FALSE \ -mCG_extend_parms=FALSE \ -mGLOB_as_output_backup_file_name=/tmp/iccEAcip0as_.s \ -mIPOPT_activate \ -mGLOB_machine_model=GLOB_MACHINE_MODEL_EFI2 \ -mGLOB_product_id_code=0x22006d8e \ -mCG_bnl_movbe=T \ -mP3OPT_use_mspp_call_convention \ -mPGOPTI_value_profile_use=T \ -mP2OPT_il0_array_sections=TRUE \ -mP2OPT_hlo \ -mP2OPT_hpo_rtt_control=0 \ -mIPOPT_args_in_regs=0 \ -mP2OPT_disam_assume_nonstd_intent_in=FALSE \ -mGLOB_imf_mapping_library=ICCDIR/Linux-i686/12.1/composer_xe_2011_sp1.11.339/bin/intel64/libiml_attr.so \ -mIPOPT_link \ -mIPOPT_ipo_activate \ -mIPOPT_mo_activate \ -mIPOPT_source_files_list=/tmp/icc6CLpN2slis \ -mIPOPT_mo_global_data \ -mIPOPT_link_script_file=/tmp/iccGjh8Emscript \ "-mIPOPT_link_version=2.16.91.0.5 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"" \ -mIPOPT_il_in_obj \ -mIPOPT_ipo_activate_warn=FALSE \ -mIPOPT_obj_output_file_name=/tmp/ipo_iccut2hB7.o \ "-mGLOB_linker_version=2.16.91.0.5 20051219 (SUSE Linux)" \ -mGLOB_long_size_64 \ -mGLOB_routine_pointer_size_64 \ -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS \ -mGLOB_async_unwind_tables=TRUE \ -mGLOB_obj_output_file=/tmp/ipo_iccut2hB7.o \ -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE \ -mP1OPT_source_file_name=ipo_out.c \ object.o \ -mIPOPT_object_files=/tmp/iccs0aXsrolis \ -mIPOPT_assembly_files=/tmp/iccaF1CkLalis \ -mIPOPT_generated_tempfiles=/tmp/iccc8qjc5elis \ -mIPOPT_embedded_object_base_name=/tmp/iccEQl03oeobj \ -mIPOPT_cmdline_link_new_name=/tmp/iccilOHVIllis ld \ /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 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[/bash] 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 object?

Thanks,

Daniel
0 Kudos
3 Replies
Sukruth_H_Intel
Employee
107 Views

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 12.1.5.339 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
./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.

Regards,
Sukruth H.V

djunglas
New Contributor I
107 Views

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 (12.1.5.339).
Could you run 'nm libobject.so | grep strdup'? For me this gives
[bash]U __intel_sse2_strdup[/bash]indicating that the symbol is not defined.

Thanks,

Daniel
Georg_Z_Intel
Employee
107 Views

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 12.1.5.339 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
Reply