π
<-
Chat plein-écran
[^]

Compiling multiple .cpp files

C, C++, ASM...

Compiling multiple .cpp files

Unread postby Rankail » 27 Aug 2021, 18:38

When programming in cpp i like to create a .cpp and .h file for every bigger class. Is it possible to compile multiple cpp-files into one tns-file? And how can i set it up? What do i need to change in the makefile?
User avatar
Rankail
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Level up: 64%
 
Posts: 21
Joined: 09 Nov 2019, 18:33
Location: Germany, North Rhine-Westfalia
Gender: Male
Calculator(s):
MyCalcs profile
Class: 12

Re: Compiling multiple .cpp files

Unread postby Ti64CLi++ » 27 Aug 2021, 18:39

Yes of course. You have to specify every source file to your command.
I suggest you create a Makefile in order to do everything for you. And the SDK already has a pretty useful command to create a ready-to-use makefile.
Use nspire-tools new <name of the project> ;)
Image
User avatar
Ti64CLi++Modo
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 32.3%
 
Posts: 3441
Images: 75
Joined: 04 Jul 2014, 14:40
Location: Clermont-Ferrand 63
Gender: Male
Calculator(s):
MyCalcs profile
Class: ENS Rennes
GitHub: Ti64CLi

Re: Compiling multiple .cpp files

Unread postby Rankail » 27 Aug 2021, 18:45

I have already created a makefile with that command. I wanted to know if i need to change anything in it to compile other cpp files int the same directory. It sounds like i don't need to do anything?
User avatar
Rankail
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Level up: 64%
 
Posts: 21
Joined: 09 Nov 2019, 18:33
Location: Germany, North Rhine-Westfalia
Gender: Male
Calculator(s):
MyCalcs profile
Class: 12

Re: Compiling multiple .cpp files

Unread postby Ti64CLi++ » 27 Aug 2021, 18:47

No, just put all your .cpp and .h(pp) files in the same directory as the makefile, and you're good to go. Just type make in your console ;)
Image
User avatar
Ti64CLi++Modo
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 32.3%
 
Posts: 3441
Images: 75
Joined: 04 Jul 2014, 14:40
Location: Clermont-Ferrand 63
Gender: Male
Calculator(s):
MyCalcs profile
Class: ENS Rennes
GitHub: Ti64CLi

Re: Compiling multiple .cpp files

Unread postby Rankail » 27 Aug 2021, 19:02

Nice. That's way easier than i thought. Thanks.
User avatar
Rankail
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Level up: 64%
 
Posts: 21
Joined: 09 Nov 2019, 18:33
Location: Germany, North Rhine-Westfalia
Gender: Male
Calculator(s):
MyCalcs profile
Class: 12

Re: Compiling multiple .cpp files

Unread postby SlyVTT » 27 Aug 2021, 19:16

It is even not mandatory to have everything in the same directory than the makefile.
All subdirectories placed in the folder where is the makfile will also be scanned and treated.
Be aware of that cause it can be usefull for sorting files but can also create some issues if your project contains several versions of file with same function names.

Br

Sly
Some works in progress :
The GUI Toolkit NF for nSpireMyShmup for fxCG-50Magic Light for Casio Graph 90+E
and
Magic Light for nSpire CX/CX-II
Simple Text Editor for nSpireOutRun for Casio Graph 90+E
95%
50%
100%
75%
100%
And more to come ... stay tuned
User avatar
SlyVTTPremium
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Level up: 43.1%
 
Posts: 484
Images: 31
Joined: 19 Jan 2021, 09:41
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
GitHub: SlyVTT

Re: Compiling multiple .cpp files

Unread postby Rankail » 27 Aug 2021, 23:22

Oh. Even better than i thought
User avatar
Rankail
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Level up: 64%
 
Posts: 21
Joined: 09 Nov 2019, 18:33
Location: Germany, North Rhine-Westfalia
Gender: Male
Calculator(s):
MyCalcs profile
Class: 12

Re: Compiling multiple .cpp files

Unread postby Ti64CLi++ » 28 Aug 2021, 09:32

Oh yeah right, I had forgotten about the subdirectories ^^
Image
User avatar
Ti64CLi++Modo
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 32.3%
 
Posts: 3441
Images: 75
Joined: 04 Jul 2014, 14:40
Location: Clermont-Ferrand 63
Gender: Male
Calculator(s):
MyCalcs profile
Class: ENS Rennes
GitHub: Ti64CLi


Return to Native: Ndless, Linux, ...

Who is online

Users browsing this forum: No registered users and 17 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
Phi NumWorks jailbreak
123
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1251 utilisateurs:
>1234 invités
>12 membres
>5 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)