How do you compile/build/execute a C++ project in Geany?

前端 未结 6 488
予麋鹿
予麋鹿 2021-01-04 09:00

I really didn\'t think it would be this difficult. Geany clearly has the ability to create projects, add files to the projects, compile the individual files, but then even a

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 09:29

    Geany doesn't compile projects. You can use a makefile to serve the same purpose; however, you have to make it manually or use an external command that can figure out dependencies. Geany's "make" command will use the make file called "makefile" by default, so you can simply give your make file that name and all should be well.

    all: hello
    
    hello: main.o factorial.o hello.o
        g++ main.o factorial.o hello.o -o hello
    
    main.o: main.cpp
        g++ -c main.cpp
    
    factorial.o: factorial.cpp
        g++ -c factorial.cpp
    
    hello.o: hello.cpp
        g++ -c hello.cpp
    
    clean:
        rm -rf *o hello
    

    Example taken from here. You can find more detailed information on that page as well.

提交回复
热议问题