0

I'm trying to link an executable with an external library called libr. I'm not looking for help with that library specifically, only the linker error, which is pasted below:

undefined reference to `r_asm_new()'

Ok, so I double check my link command:

-lr_core -lr_config -lr_cons -lr_cmd -lr_util -lr_flags -lr_asm -lr_lib -lr_debug -lr_hash -lr_bin -lr_lang -lr_io -lr_anal -lr_parse -lr_bp -lr_egg -lr_reg -lr_search -lr_syscall -lr_sign -lr_diff -lr_socket -lr_fs -lr_magic -lr_db

and it seems to contain all the libraries that libr package has. I double the the libr_asm.so file with objdump:

$ objdump -T libr_asm.so.0.9.3git | grep r_asm_new
  00000000000ca66a g    DF .text    0000000000000149  Base        r_asm_new

so as far as I can tell the -l_asm flag should have done it. I'm linking a c library to a c++ executable, but I can't think of how that could change the situation.

Thanks.

EDIT: The full link line:

/usr/bin/c++       CMakeFiles/main.dir/main.cc.o CMakeFiles/main.dir/ElfFile.cc.o CMakeFiles/main.dir/ElfFileSection.cc.o CMakeFiles/main.dir/ElfFileDefinitions.cc.o CMakeFiles/main.dir/SectionsWindow.cc.o CMakeFiles/main.dir/SectionView.cc.o  -o main -rdynamic -L/home/chris/radare_install/lib -lboost_filesystem-mt -lboost_system-mt -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 -lgtksourceviewmm-3.0 -lgtkmm-3.0 -lgtksourceview-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lglibmm-2.4 -lcairomm-1.0 -lsigc-2.0 -lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 -lr_core -lr_config -lr_cons -lr_cmd -lr_util -lr_flags -lr_lib -lr_debug -lr_hash -lr_bin -lr_lang -lr_io -lr_anal -lr_parse -lr_bp -lr_egg -lr_reg -lr_search -lr_syscall -lr_sign -lr_diff -lr_socket -lr_fs -lr_magic -lr_db -lr_asm -Wl,-rpath,/home/chris/radare_install/lib 
4

1 回答 1

4

....关于这个问题的评论提醒了我:

extern "C" {
  #include "foo.h"
}
于 2013-02-10T20:06:53.810 回答