c++ - What's the differece between of link to a dynamic file and as a input object? -


i use g++ link project (an executable mono_kitti) , project dependent on thirdparty library pangolin. when link action -lpangolin option:

g++ -l../../lib -lorb_slam2 -lpangolin mono_kitti.o -o mono_kitti 

it returns:

mono_kitti.o:(.data+0x0): undefined reference `vtable pangolin::handler' mono_kitti.o:(.data+0x8): undefined reference `vtable pangolin::handlerscroll' mono_kitti.o: in function `pangolin::handler::~handler()': mono_kitti.cc:(.text._zn8pangolin7handlerd2ev[_zn8pangolin7handlerd5ev]+0x13): undefined reference `vtable pangolin::handler' mono_kitti.o: in function `pangolin::handlerscroll::~handlerscroll()': mono_kitti.cc:(.text._zn8pangolin13handlerscrolld2ev[_zn8pangolin13handlerscrolld5ev]+0x13): undefined reference `vtable pangolin::handlerscroll' collect2: error: ld returned 1 exit status 

but when use command:

g++ -l../../lib -lorb_slam2 mono_kitti.o /usr/local/lib/libpangolin.so -o mono_kitti 

it succeeded.

but failed again when tried swap order of them:

g++ -l../../lib -lorb_slam2 /usr/local/lib/libpangolin.so mono_kitti.o -o mono_kitti 

and returns things identical first case above (-lpangolin option).

i'm confused these results, can explain differece between them? many thanks!

when linker sees library (the -lpangolin option in case), doesn't yet have unresolved references library, discards it.

if put object file before library, command line e.g.

g++ mono_kitti.o -l../../lib -lorb_slam2 -lpangolin -o mono_kitti 

then linker have unresolved references mono_kitti.o , pull them libraries.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -