- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am having a difficult time trying to compile a trivial c++ program that containing a stdlib call.
I have narrowed down the problem with trying to statically or dynamically link the latest version of gcc’s libraries (static examples shown below.)
If I were to dynamically link the library, I had to make sure that my LD_LIBRARY_PATH is set correctly. Linking to an older version works fine (example is shown at the bottom)
Any ideas what I could be doing wrong? I am trying to upgrade our compilers to the latest and this is blocking me.
Thanks,
Nick
a.cpp:
#include <iostream>
int main(int argc, char *argv[])
{
int foo = 5;
foo += 5;
int bar = foo;
std::cout <<"Hello World!" << std::endl; //segfaults here
}
Using ICC 14.0 with multiple GCC versions:
machine> /<path>/14.0.1/bin/icpc -gxx-name=/<path>/gcc/4.8.0/bin/g++ a.cpp -m32 -static && a.out
Segmentation fault
machine> /<path>/14.0.1/bin/icpc -gxx-name=/<path>/gcc/4.7.2/bin/g++ a.cpp -m32 -static && a.out
Segmentation fault
machine> /<path>/14.0.1/bin/icpc -gxx-name=/<path>/gcc/4.7.0/bin/g++ a.cpp -m32 -static && a.out
Segmentation fault
machine> /<path>/14.0.1/bin/icpc -gxx-name=/<path>/gcc/4.6.2/bin/g++ a.cpp -m32 -static && a.out
Hello World!
machine> /<path>/14.0.1/bin/icpc -gxx-name=/<path>/gcc/4.4.2/bin/g++ a.cpp -m32 -static && a.out
Hello World!
Using ICC 13.0 with multiple GCC versions:
machine> /<path>/13.0.0/composer_xe_2013.0.079/bin/ia32/icpc -gxx-name=/<path>/gcc/4.8.0/bin/g++ a.cpp -static && a.out
Segmentation fault
machine> /<path>/13.0.0/composer_xe_2013.0.079/bin/ia32/icpc -gxx-name=/<path>/gcc/4.7.2/bin/g++ a.cpp -static && a.out
Segmentation fault
machine> /<path>/13.0.0/composer_xe_2013.0.079/bin/ia32/icpc -gxx-name=/<path>/gcc/4.7.0/bin/g++ a.cpp -static && a.out
Segmentation fault
machine> /<path>/13.0.0/composer_xe_2013.0.079/bin/ia32/icpc -gxx-name=/<path>/gcc/4.6.2/bin/g++ a.cpp -static && a.out
Hello World!
machine> /<path>/13.0.0/composer_xe_2013.0.079/bin/ia32/icpc -gxx-name=/<path>/gcc/4.4.2/bin/g++ a.cpp -static && a.out
Hello World!
Using ICC 12.0 and gcc 4.6.2 (Our current compiler configuration):
machine> /<path>/12.1.3/composer_xe_2011_sp1.9.293/bin/ia32/icpc -gxx-name=/<path>/gcc/4.6.2/bin/g++ a.cpp -static && a.out
Hello World!
Dynamic link example:
machine> /<path>/icc/14.0.0/bin/icpc -gxx-name=/<path>/gcc/4.8.0/bin/g++ a.cpp -m32
machine> ldd a.out
linux-gate.so.1 => (0xffffe000)
libm.so.6 => /lib/libm.so.6 (0xf7fb9000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xf7ed5000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xf7eca000)
libc.so.6 => /lib/libc.so.6 (0xf7d88000)
libdl.so.2 => /lib/libdl.so.2 (0xf7d82000)
/lib/ld-linux.so.2 (0x56555000)
machine> a.out
Hello World!
machine> setenv LD_LIBRARY_PATH /<path>/gcc/4.8.0/lib
machine> ldd a.out
linux-gate.so.1 => (0xffffe000)
libm.so.6 => /lib/libm.so.6 (0xf7fb9000)
libstdc++.so.6 => /<path>/gcc/4.8.0/lib/libstdc++.so.6 (0xf7ed0000)
libgcc_s.so.1 => /<path>/gcc/4.8.0/lib/libgcc_s.so.1 (0xf7eb5000)
libc.so.6 => /lib/libc.so.6 (0xf7d73000)
libdl.so.2 => /lib/libdl.so.2 (0xf7d6d000)
/lib/ld-linux.so.2 (0x56555000)
machine> a.out
Segmentation fault
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
$ icpc q039659.cpp -static -gxx-name=/opt/gcc/gcc-4.8.1/bin/g++ -m32 -L/opt/intel/composer_xe_2013_sp1.1.106/compiler/lib/ia32/
$ ./a.out
Hello World!
you can add '-v' to make sure linking right .
Thank you.
--
QIAOMIN.Q
Intel Developer Support
Please participate in our redesigned community support web site:
User forums: http://software.intel.com/en-us/forums/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I still am getting a seg fault:
machine> /path/icc/14.0.0/bin/icpc -gxx-name=/path/gcc/4.8.0/bin/g++ a.cpp -m32 -static -L/path/icc/14.0.0/composer_xe_2013_sp1.1.106/compiler/lib/ia32/
machine>a.out
Segmentation fault
-v shows: ld /usr/lib/../lib/crt1.o /usr/lib/../lib/crti.o /path/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/x86_64-suse-linux/4.8.0/32/crtbeginT.o -static -m elf_i386 -L/path/icc/14.0.0/composer_xe_2013_sp1.1.106/compiler/lib/ia32/ -o a.out -L/path/tools/icc/14.0.0/composer_xe_2013_sp1.1.106/compiler/lib/ia32 -L/path/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/x86_64-suse-linux/4.8.0/32/ -L/path/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/x86_64-suse-linux/4.8.0/../../../../x86_64-suse-linux/lib/../lib/ -L/path/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/x86_64-suse-linux/4.8.0/../../../../lib/ -L/lib/../lib/ -L/usr/lib/../lib/ -L/path/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/x86_64-suse-linux/4.8.0/32 -L/path/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/x86_64-suse-linux/4.8.0/ -L/path/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/ -L/path/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/x86_64-suse-linux/4.8.0/../../../../x86_64-suse-linux/lib/ -L/path/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/x86_64-suse-linux/4.8.0/../../../ -L/lib/ -L/usr/lib /tmp/icpcpzuMcx.o -limf -lsvml -lirng -lm -lipgo -ldecimal -lstdc++ -lgcc -lgcc_eh -lirc -lsvml -lc -lgcc -lgcc_eh -lirc_s -ldl -lc /path/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/x86_64-suse-linux/4.8.0/32/crtend.o /usr/lib/../lib/crtn.o
perhaps there is a problem with the installation of icc14 or gcc4.8? Are there any diagnostics I can do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should run with icpc installed in original position (matching its libraries), with paths determined at install time, sourceing the installed compilervars script.
Then you should be able do do
icpc -V
and see the correct version.
Also, I think it's better to set up so that e.g.
g++ -v -m32 empty.cpp
g++ -m32 --print-search-dirs
give the expected results, rather than depending on not-so-well-tested options.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
turns out icpc was using the default "ld", which is an older version (2.16.91)
"/..path../pkgs/gcc/4.8.1/bin/ld" is version (2.23.2)
specifying "-Qlocation,ld,/..path../pkgs/gcc/4.8.1/bin/" achieved correct behavior, at least for the trivial test
/..path../icc/14.0.1/bin/icpc a.cpp -static -v -m32 -gxx-name=/..path..s/gcc/4.8.1/bin/g++ -Qlocation,ld,/..path../gcc/4.8.1/bin/ && a.out
Hello World!
are there any other tools I should specify the correct location?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And as i observed that without adding the -L/opt/intel/composer_xe_2013_sp1.1.106/compiler/lib/ia32/ ,linker would always try to link with intel64 libraries ,also caused linking errors.
$ icpc q039659.cpp -static -gxx-name=/opt/gcc/gcc-4.8.1/bin/g++ -m32 -L/opt/intel/composer_xe_2013_sp1.1.106/compiler/lib/ia32/
$ ./a.out
Hello World!
Ths is the one with success without specifying the ld location.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are correct Qiaomin, I went back and again tried adding the option -L/opt/intel/composer_xe_2013_sp1.1.106/compiler/lib/ia32/ , it does work without specifying the ld location. I'm not sure why it didn't work for me the first time I tried.
Thanks to all who helped,
Nick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This thread helped me solve crazy errors. I think if you're using "-gxx-name" you should get a warning if you're not also changing the linker that you might end up in funky situations.
![](/skins/images/5955FC319B8C26F693C63AD242EC106A/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page