Cannot link to shared library

前端 未结 1 455
情深已故
情深已故 2021-01-27 13:11

I\'m trying to compile a minimal shared library and link to it and have been failing for two hours now. Here is ALL the code:

// rect.h
class Rect{
  private:
           


        
1条回答
  •  抹茶落季
    2021-01-27 13:37

    The libraries have to go after the local translation units:

    g++ -L. -Wl,-rpath,'.' client.cpp -o client -lrect
    #                                           ^^^^^^
    

    It has to do with how unresolved symbols are looked up by the linker; search the internet for a plethora of information on this if you're curious.

    0 讨论(0)
提交回复
热议问题