c++linuxgeany

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


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 after googling it I could not find a clear description of how to build and execute the project... It's pretty annoying because I really like the simplicity of Geany and its clean, uncluttered workspace, but this could be a deal breaker.


Solution

  • 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.