What does the compile-time error “Undefined symbols for architecture x86_64” mean?

后端 未结 1 1670
北荒
北荒 2020-12-13 09:12

I\'m trying to program a graph class using an adjacent list from an example in my C++ text book, and when I compile using this command: Code: g++ -o prog program.cpp ...I ge

相关标签:
1条回答
  • 2020-12-13 09:38

    When you compile the file, the compiler invokes the linker which tries to generate an executable. But it cannot because you didn't provide a function named main which is the function that will be executed when your program is launched.

    Either you don't want to run the linker because you want to compile several files separately then combine then. In that case, use the -c flag to tell the compiler to skip the link stage.

    Or either you want to execute the compiled file. Then you need to implement the function main.

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