I've been trying to move a project over from Xcode to Linux (Ubuntu x86 for now, but hopefully the statically-linked executable will run on an x86 CentOS machine? I hope I hope?). I have the whole project compiling but it fails at the linking stage-- it's giving me undefined references for all functions defined by IPP. This is probably something really small and silly but I've been beating my head over this for a couple days now and I can't get it to work.
我一直在尝试将项目从Xcode转移到Linux(现在是Ubuntu x86,但希望静态链接的可执行文件可以在x86 CentOS机器上运行?我希望我希望?)。我有整个项目编译,但它在链接阶段失败 - 它为我提供了由IPP定义的所有函数的未定义引用。这可能是一件非常小而且愚蠢的事情,但是我已经在这几天打了很久但我无法让它发挥作用。
Here's the compile statement (I also have a makefile that's generating the same errors):
这是编译语句(我还有一个生成相同错误的makefile):
g++ -static /opt/intel/ipp/6.0.1.071/ia32/lib/libippiemerged.a /opt/intel/ipp/6.0.1.071/ia32/lib/libippimerged.a /opt/intel/ipp/6.0.1.071/ia32/lib/libippsemerged.a /opt/intel/ipp/6.0.1.071/ia32/lib/libippsmerged.a /opt/intel/ipp/6.0.1.071/ia32/lib/libippcore.a -pthread -I /opt/intel/ipp/6.0.1.071/ia32/include -I tools/include -o main main.cpp pick_peak.cpp get_starting_segments.cpp get_segment_timing_differences.cpp recast_and_normalize_wave_file.cpp rhythm_score.cpp pitch_score.cpp pitch_curve.cpp tools/source/LocalBuffer.cpp tools/source/wave.cpp distance.cpp
g ++ -static /opt/intel/ipp/6.0.1.071/ia32/lib/libippiemerged.a /opt/intel/ipp/6.0.1.071/ia32/lib/libippimerged.a/opt/intel/ipp/6.0.1.071/ ia32 / lib / libippsemerged.a /opt/intel/ipp/6.0.1.071/ia32/lib/libippsmerged.a /opt/intel/ipp/6.0.1.071/ia32/lib/libippcore.a -pthread -I / opt / intel / ipp / 6.0.1.071 / ia32 / include -I tools / include -o main main.cpp pick_peak.cpp get_starting_segments.cpp get_segment_timing_differences.cpp recast_and_normalize_wave_file.cpp rhythm_score.cpp pitch_score.cpp pitch_curve.cpp tools / source / LocalBuffer.cpp tools / source / wave.cpp distance.cpp
...and here is the beginning of the long list of linker errors:
...这是链接器错误的长列表的开头:
./main.o: In function `main':
main.cpp:(.text+0x13f): undefined reference to `ippsMalloc_16s'
main.cpp:(.text+0x166): undefined reference to `ippsMalloc_32f'
main.cpp:(.text+0x213): undefined reference to `ippsMalloc_16s'
Any ideas? FWIW, these are the IPP dependencies in my Xcode project that builds, links, and runs without a problem: "-lippiemerged", "-lippimerged", "-lippsemerged", "-lippsmerged", "-lippcore",
有任何想法吗? FWIW,这些是我的Xcode项目中的IPP依赖项,它构建,链接和运行没有问题:“-lippiemerged”,“ - lippimerged”,“ - lippsemerged”,“ - lippsmerged”,“ - lippcore”,
Thanks!
2 个解决方案
#1
Your linking problem is likely due to the fact that your link line is completely backwards: archive libraries should follow source and object files on command line, not precede them. To understand why the order matters, read this.
您的链接问题可能是由于您的链接线完全倒退:存档库应该在命令行上跟随源文件和目标文件,而不是在它们之前。要理解订单的重要性,请阅读此内容。
Also note that on Linux statically linked executables are significantly less portable than dynamically linked ones. In general, if you link system libraries dynamically on an older Linux system, it will work on all newer systems (I use ancient RedHat 6.2, and I haven't seen a system on which my executable will not run). This is not true for completely static executables; they may crash in all kinds of "interesting" ways when moved to a system with a different libc from the one against which they were linked.
另请注意,在Linux上,静态链接的可执行文件的可移植性远低于动态链接的可执行文件。通常,如果您在较旧的Linux系统上动态链接系统库,它将适用于所有较新的系统(我使用古老的RedHat 6.2,我没有看到我的可执行文件无法运行的系统)。对于完全静态的可执行文件,情况并非如此;当移动到具有与它们链接的libc不同的libc的系统时,它们可能以各种“有趣”的方式崩溃。
#2
I had problems with linking code with the v 6 of the ipp; using the v11 version of the compiler (with the included updates to the ipp) mysteriously fixed them. Granted, that was with a windows platform, but I was getting 8u versions of functions to compile and no 32f versions, despite both being listed as valid in the documentation.
我在将代码与ipp的v 6链接时遇到了问题;使用v11版本的编译器(包含ipp的更新)神秘地修复了它们。当然,这是一个Windows平台,但我得到了8u版本的函数进行编译,没有32f版本,尽管两者都被列为有效的文档。
#1
Your linking problem is likely due to the fact that your link line is completely backwards: archive libraries should follow source and object files on command line, not precede them. To understand why the order matters, read this.
您的链接问题可能是由于您的链接线完全倒退:存档库应该在命令行上跟随源文件和目标文件,而不是在它们之前。要理解订单的重要性,请阅读此内容。
Also note that on Linux statically linked executables are significantly less portable than dynamically linked ones. In general, if you link system libraries dynamically on an older Linux system, it will work on all newer systems (I use ancient RedHat 6.2, and I haven't seen a system on which my executable will not run). This is not true for completely static executables; they may crash in all kinds of "interesting" ways when moved to a system with a different libc from the one against which they were linked.
另请注意,在Linux上,静态链接的可执行文件的可移植性远低于动态链接的可执行文件。通常,如果您在较旧的Linux系统上动态链接系统库,它将适用于所有较新的系统(我使用古老的RedHat 6.2,我没有看到我的可执行文件无法运行的系统)。对于完全静态的可执行文件,情况并非如此;当移动到具有与它们链接的libc不同的libc的系统时,它们可能以各种“有趣”的方式崩溃。
#2
I had problems with linking code with the v 6 of the ipp; using the v11 version of the compiler (with the included updates to the ipp) mysteriously fixed them. Granted, that was with a windows platform, but I was getting 8u versions of functions to compile and no 32f versions, despite both being listed as valid in the documentation.
我在将代码与ipp的v 6链接时遇到了问题;使用v11版本的编译器(包含ipp的更新)神秘地修复了它们。当然,这是一个Windows平台,但我得到了8u版本的函数进行编译,没有32f版本,尽管两者都被列为有效的文档。