KVM-VMI / libvmi

The official home of the LibVMI project is at https://github.com/libvmi/libvmi.
GNU Lesser General Public License v3.0
11 stars 9 forks source link

undefined reference to errors #41

Open tomcruiseqi opened 8 months ago

tomcruiseqi commented 8 months ago

Hello:

When I build with cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/programs/mylibvmi -DENABLE_KVM=ON -DENABLE_XEN=OFF -DENABLE_BAREFLANK=OFF and then run make -j6, there are so many undefined references errors:

/usr/bin/ld: CMakeFiles/vmifs.dir/vmifs.c.o: in function `vmifs_read':
/home/qzt/fuzzers/kvm-vmi/libvmi/tools/vmifs/vmifs.c:94: undefined reference to `g_try_malloc0'
/usr/bin/ld: /home/qzt/fuzzers/kvm-vmi/libvmi/tools/vmifs/vmifs.c:99: undefined reference to `g_free'
/usr/bin/ld: /home/qzt/fuzzers/kvm-vmi/libvmi/tools/vmifs/vmifs.c:102: undefined reference to `g_free'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_direct_hash'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_slist_free_full'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_malloc'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_queue_unlink'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_hash_table_remove'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_str_equal'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_slist_free'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_hash_table_remove_all'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_int64_equal'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_hash_table_lookup'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_queue_get_length'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_queue_find_custom'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_queue_pop_tail'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_strconcat'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_hash_table_new'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_slist_find_custom'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_slist_prepend'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_hash_table_iter_next'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_direct_equal'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_queue_foreach'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_hash_table_new_full'
/usr/bin/ld: ../../libvmi/libvmi.so.0.0.15: undefined reference to `g_hash_table_size'

After many tries, I found that this code (line 33 in [ROOT]/CMakeLists.txt) is doing the bad thing: string(REGEX REPLACE "-l" "" GLIB_LDFLAGS ${GLIB_LDFLAGS}) when i comment out this line, everything works fine.

I don't know if there will be some other problems, so I made this issue.

PawBud commented 4 months ago

I tried something different(alongside this). I simply switched the version of CMake (from 3.25.1 which i was using and getting the same error) to 3.2.0, due to this thread .

TLDR:- It seems to be a CMake 3.21+ related issue