我正在尝试使用gcc(5.3)编译一个大代码,这是用icpc编译的。(我已经加载了mkl库)编译成功但是出现以下警告:
warning: narrowing conversion of 'p_jShell->simint_shell::nprim' from 'int' to
'unsigned int' inside { } [-Wnarrowing]
{ p_iShell->nprim, p_jShell->nprim };
但我得到运行时错误'undefined referece'到__intel_ssse3_rep_memcpy,_mm_free,_mm_malloc,__ svml_pow4,_intel_fast_memset等..
In function `simgms_oei(std::vector<std::vector<simint_shell, std::allocator<simint_shell> >, std::allocator<std::vector<simint_shell, std::allocator<simint_shell> > > >&, std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, std::vector<std::vector<unsigned int, std::allocator<unsigned int> >, std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >&, unsigned int, AtomData&)':
/home/..../simgms_oei.cpp:126: undefined reference to `oed__memory_ovl_batch_'
..
..
In function `simint_copy_shell':
shell.c:(.text+0x126): undefined reference to `__intel_ssse3_rep_memcpy'
.
shell.c:(.text+0x32fe): undefined reference to `_mm_free'
shell.c:(.text+0x335c): undefined reference to `_mm_malloc'
.
ostei_p_s_f_p.c:(.text+0x27f): undefined reference to `_intel_fast_memset'
.
..
..
我怀疑这可能来自链接问题。我链接了gcc lib目录,但我不确定我需要在这里使用哪些库。有什么建议?有谁看到我在这里做错了什么?谢谢!
gcc -mavx -g -O -O1 -std=c++11 -L/opt/shared/sw/x86_64-unknown-linux-gnu/gcc/5.3.0-rhel6/lib64 -libstdc -libsupc++ -libtsan -libubsan -libvtv -libquadmath -libgcc_s -libgcj -L/opt/intel/composer_xe_2013.5.192/mkl/lib/intel64 -libmkl_mc -libmkl_sequential -libmkl_gf_ilp64 -libmkl_avx -libmkl_lapack95_lp64 -libmkl_intel_lp64 -libmkl_core -lmkl_gnu_thread -I/opt/intel/composer_xe_2013.5.192/mkl/include -I/opt/shared/sw/x86_64-unknown-linux-gnu/gcc/5.3.0-rhel6/include -I/***/simint/include -DDEBUG -DMKL_ILP64 -MMD -MP -MF"simgms_init.d" -MT"simgms_init.d" -c -o "simgms_init.o" "../simgms_init.cpp"
答案 0 :(得分:0)
我尝试将库中的所有cpp文件(simgms_oei.cpp等等)编译成并尝试下面的nm命令:
>> nm libsimint.a |grep __intel_ssse3_rep_memcpy
U __intel_ssse3_rep_memcpy
>> nm libsimint.a |grep simint_copy_shell
0000000000000090 T simint_copy_shell
当您查找U和T时,它意味着以下内容: simint_copy_shell函数在代码中提到但是__intel_ssse3_rep_memcpy没有在其他libray中定义我们的libsimint是用
编译的结论是库是用icpc编译的,我必须先用gcc重新编译它,然后才能在上面的步骤中链接它。
将Wl,命令添加到链接器脚本,如下所示:
--Wl,--start-group -L/opt/share... -lsomelib -lsomeotherlib -L/xxx/...-lsomelib -Wl,--end-group
摆脱因链接顺序而导致的其他错误。