Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
2

How to change how c++ is executed (also makefiles ?)

BlueWhispers
BlueWhispers

Hi ! I have the following architecture :
sources
|main.cpp
|other.cpp
headers
|other.hpp

When I run I have the following error :
unable to run, main file "main.cpp" not found

How do I get to tell it that my main.cpp file is in the 'sources' folder ?

Also, can I create and configure a makefile in replit ?

Thanks in advance !

1 year ago

Voters

Comments

TopNew
3
19ecal
19ecal

You can create a makefile. Write your makefile (I presume you know how to do that), then your project will look something like this

. ├── headers │   └── other.hpp ├── makefile └── sources ├── main.cpp └── other.cpp

Then make a file called .replit in the root of your project
In it put the following lines:

run = "make && ./path/to/executable"

Then every time you hit the run button the commands in .replit (i.e make && ./path/to/executable) will be run.
Alternatively you could put in your .replit file

run = "g++ -o main main.cpp && ./main"

to run the compiler directly instead of through your makefile

1 year ago
Load more