C++ undefined reference to defined function

前端 未结 6 1007

I cannot figure out why this is not working. I will put up all three of my files and possibly someone can tell me why it is throwing this error. I am using g++ to compile the

6条回答
  •  無奈伤痛
    2021-02-03 20:37

    If you are including a library which depends on another library, then the order of inclusion is also important:

    g++ -o MyApp MyMain.o -lMyLib1 -lMyLib2
    

    In this case, it is okay if MyLib1 depends on MyLib2. However, if there reverse is true, you will get undefined references.

提交回复
热议问题