Using only g++ works, but not “g++ -c” and ld

后端 未结 4 1667
挽巷
挽巷 2020-12-06 06:03

I have the following source code in main.cpp:

#include 
#include 

int main() {
    std::cout << \"Hi\" << std::en         


        
4条回答
  •  北海茫月
    2020-12-06 06:43

    I think if you use ld directly it does not include the C++ libraries by default. You can use g++ to do the linking as well, it will call ld with the correct settings.

    g++ -c main.cpp
    g++ -o main main.o
    

提交回复
热议问题