MegEngine / mperf

mperf是一个面向移动/嵌入式平台的算子性能调优工具箱
Apache License 2.0
169 stars 27 forks source link

/usr/bin/ld: ../build-x86/third_party/libpfm4//libpfm.a(pfmlib_common.c.o):(.data.rel.ro+0x38): undefined reference to `amd64_k8_revb_support #6

Open wwangxinhao opened 1 year ago

wwangxinhao commented 1 year ago

g++ main.cpp -o test --std=c++11 -I ../include/ -I ../build-x86 -L ../build-x86/eca/xpmu/ -L ../build-x86/eca/tma/ -L ../build-x86/third_party/libpfm4/ -lmperf_xpmu -lpfm_x86 -lpfm
/usr/bin/ld: /tmp/ccRZS8u0.o: in function main': main.cpp:(.text+0x280): undefined reference toset_cpu_thread_affinity_spec_core(unsigned long)' /usr/bin/ld: main.cpp:(.text+0x2b5): undefined reference to mperf::WallTimer::WallTimer()' /usr/bin/ld: main.cpp:(.text+0x2ef): undefined reference tomperf::WallTimer::get_msecs() const' /usr/bin/ld: ../build-x86/third_party/libpfm4//libpfm.a(pfmlib_common.c.o):(.data.rel.ro+0x20): undefined reference to netburst_support' /usr/bin/ld: ../build-x86/third_party/libpfm4//libpfm.a(pfmlib_common.c.o):(.data.rel.ro+0x28): undefined reference tonetburst_p_support' /usr/bin/ld: ../build-x86/third_party/libpfm4//libpfm.a(pfmlib_common.c.o):(.data.rel.ro+0x30): undefined reference to amd64_k7_support' /usr/bin/ld: ../build-x86/third_party/libpfm4//libpfm.a(pfmlib_common.c.o):(.data.rel.ro+0x38): undefined reference toamd64_k8_revb_support

youzhedian commented 1 year ago

看上去像是最后三个.a的链接顺序有问题以及是不是漏了libmperf.a 和 libmperf_tma.a,因为repo readme中是假设用户用cmake install和find_package来集成mperf,那样就不会遇到这些问题。 这里几个.a的正确链接顺序: libmperf.a libmperf_tma.a libmperf_xpmu.a libpfm.a libpfm_x86.a

编写一个简单的hello world程序,下面这条路是测试过的

cmake -S . -B "build-x86" -DMPERF_ENABLE_PFM=ON -DCMAKE_INSTALL_PREFIX=~/mperf_install
cmake --build "build-x86" --config Release
cmake --build ./build-x86/ --target install

用find_package

set(mperf_DIR ~/mperf_install/lib/cmake/mperf)
find_package(mperf REQUIRED)
target_link_libraries(main PRIVATE mperf::mperf)