C++ 如何在makefile中包含字符串fstream和iostream库

C++ 如何在makefile中包含字符串fstream和iostream库,c++,linux,makefile,include,libraries,C++,Linux,Makefile,Include,Libraries,我需要编译和运行几个文件,但我不知道如何将标准库包含到我的makefile中。在这种情况下,我需要包括string、fstream和iostream库。我在网上的搜索结果令人失望。我认为使用libraryname或-llibraryname可以包含它们,但我错了。我每次都给我一个错误。编译的文件是用C++编写的。谢谢你抽出时间 # default command, builds an executable called "magasin". # executable can be called

我需要编译和运行几个文件,但我不知道如何将标准库包含到我的makefile中。在这种情况下,我需要包括
string
fstream
iostream
库。我在网上的搜索结果令人失望。我认为使用
libraryname
-llibraryname
可以包含它们,但我错了。我每次都给我一个错误。编译的文件是用C++编写的。谢谢你抽出时间

# default command, builds an executable called "magasin".
# executable can be called with make magasin
all: magasin
    # link the object files into the executable.
    # the -lm option is to tell the linker to include math libraries.
    magasin: client.o panier.o produit.o rayon.o main.o
        g++ -o $@ $^ string vector iostream fstream

    # compile the Client.cpp file into the client.o object file.   
    client.o: Client.cpp Client.h                                
        g++ -o client.o -c Client.cpp string

    # compile the Produit.cpp file into produit.o object file
    produit.o: Produit.cpp Produit.h                                
        g++ -o produit.o -c Produit.cpp string

    # compile the Rayon.cpp file into the rayon.o object file.
    rayon.o: Rayon.cpp Rayon.h                                
        g++ -o rayon.o -c Rayon.cpp string vector

    # compile the Panier.cpp file into the panier.o object file.
    panier.o: Panier.cpp Panier.h
        g++ -o panier.o -c Panier.cpp string vector

    # compile the main.cpp file into the main.o object file.
    main.o: main.cpp Produit.h Rayon.h Client.h Panier.h 
        g++ -o main.o -c main.cpp string iostream fstream


# remove the executable and intermediary object files.
clean:
    rm -rf *.o

您不需要在编译器标志中显式地包含标准库。您的C++编译器将自动链接这些文件。当从shell提示符运行编译器时,您知道“如何包含标准库”吗?在makefile中使用的方法完全相同。我不确定如何从shell提示符中包含库。@Artour,Sam在咆哮。见布赖恩的评论
g++-o-client.o-c-client.cpp应该可以做到这一点。