473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to use Makefile to compile a project with multiple files ?

Recently i've just built an SFML/C++ project on Visual Studio Code using CMake and MinGW.I've successfully compiled and run a test file in my project folder.

Here's my Makefile:

Expand|Select|Wrap|Line Numbers
  1. StarFire:
  2.     g++ main.cpp -o main.exe -DSFML_STATIC    -I F:\SFMLPrj\StarFirestc\Prefixes\include    -L F:\SFMLPrj\StarFirestc\Prefixes\lib    -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lwinmm -lgdi32 -lfreetype
But then when i include more files into the folder i don't know how to modify my Makefile to compile 2 or more files.

Basically when i run my test file for the first time,i include SFML header into that test file so when the compiler(MinGW) runs,it looks into the Makefile and know that i've included SFML headers there.But when i make a new class in the folder(Game.h and Game.cpp) i put the SFML into the 'Game.h' file then include it in the test file.

Not only i don't know how the compiler would look for SFML headers and libs from now on.I also don't know how it will look for the 'Game' class and a bunch of other classes i will make in the future.

Can anyone help me ?
Jan 1 '20 #1
1 1584
Finally solve the problem,so not only do you have to link the SFML headers and library to the .exe file,the obj file also have to be linked.I just put the linking instructions(DSFML_STATIC) in front of the .o file recipe and my project compiles successfully.
Jan 1 '20 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: john townsley | last post by:
i have a .cpp file and i want to have my class and member functions in a seperate file. if i put the class heading file in a .h and the member functions for the class in a .cpp. how do i compile...
13
by: fb | last post by:
One quick question about multiple files. Let's say I had the following: #include <stdio.h> void Heading(void); int main(void) {
1
by: cyshao | last post by:
How to compile project by makefile ? I downloaded a VC package. There is not project file, but only a makefile. Could you tell me how to compile this makefile? Thanks Charles Shao^_^
5
by: farmer | last post by:
I need "include" multiple classes from multiple files such as: <%@ Page Language="C#" Debug="true" ValidateRequest="false" Src="~/Auth/Pub/Auth.cs"%> <%@ Page Language="C#" Debug="true"...
4
by: yehaimanish | last post by:
I am developing the project management system. Each Project: 1. Title, description ... , stored in mysql database 2. Upto ten files (initial description), (name in db, file in file system) 3....
8
by: SAIRAAM | last post by:
hi all i am right now examing one of the project thats avaliable.in which they have taken single log file as input. the code for it is given below. Private Sub...
11
by: grantstech | last post by:
I have successfully created a program that searches for a word in multiple files but now I need to be able to search by more than one word. I have add code from a previous discussion to my original...
3
by: vedulamanjula | last post by:
Hello sir/madam I am having some doubts in my project. Please try to help me. I completed my b.tech (cse) and I'm trying to get knowledge of small Visual Basic projects. How to insert multiple...
10
by: kimiraikkonen | last post by:
Hi, I have an app which has a listbox and when i double click an associated fileS, i want their paths to be added into listbox in my application. This code works good when i try to open a...
2
by: grandemahatma1 | last post by:
hallo, I'm pretty new to C and I'm having some problems while compiling multiple files; here what I do: I've got 3 files: 1.cpp , 2.cpp , INIT.h and these are the files: 1.cpp: #include...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.