Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/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 this issue Apr 13, 2023 · 1 comment

Comments

@wwangxinhao
Copy link

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 to set_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 to mperf::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 to netburst_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 to amd64_k8_revb_support

@youzhedian
Copy link
Collaborator

youzhedian commented Apr 21, 2023

看上去像是最后三个.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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants