LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-30-2022, 11:16 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
To have gcc compile to assembler codes too


How do we have gcc compile to assembler codes too in addition to .obj while i used to do
Code:
    g++ -S -o m.asm  m.cpp
output to assembly only ?

Please explain every gcc cli correct steps
 
Old 10-01-2022, 01:15 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,871
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Google found this: https://www.systutorials.com/generat...ing-using-gcc/
 
3 members found this post helpful.
Old 10-01-2022, 09:55 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by BudiKusasi View Post
How do we have gcc compile to assembler codes too in addition to .obj while i used to do
Code:
    g++ -S -o m.asm  m.cpp
output to assembly only ?
I'm not sure I understand your full question. Did you try that and not get assembly output?
Quote:
Originally Posted by BudiKusasi View Post
Please explain every gcc cli correct steps
This is an extremely broad request, please search for the gcc documentation and search within it to address specific questions, and if you have further questions, please be more specific.
 
1 members found this post helpful.
Old 10-01-2022, 01:22 PM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Your question is not really clear to me, but if I interpret it to mean this:

Quote:
How do I have gcc save intermediate files when compiling an executable?
See man gcc and look at the -save-temps option.

Further, your example specifically names the assembler file using the -o option, but -o names the primary output file only, so if continuing to object and linker phases the earlier intermediate files will be named based on that but you may not be able to name them explicitly (but see the -dumpbase option for more possibilities).

Quote:
Originally Posted by BudiKusasi View Post
Please explain every gcc cli correct steps
That is asking too much and would deprive you of the learning experience!

Last edited by astrogeek; 10-01-2022 at 01:26 PM.
 
Old 10-03-2022, 11:08 AM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,241

Rep: Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322
If the program is small and you just want to see the generated assembler, you can paste it here:

https://godbolt.org/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: My Nerd Life: Too Loud, Too Funny, Too Smart, Too Fat LXer Syndicated Linux News 0 01-24-2014 05:21 AM
ns2 codes for OLSR codes sukrutha Linux - Newbie 3 01-25-2012 11:42 PM
[SOLVED] How to compile .jar Java byte-codes into native machine codes? ilgaar Linux - Software 1 08-30-2010 12:52 AM
How to compile .jar Java byte-codes into native machine codes? ilgaar Linux - Software 6 08-28-2010 11:20 PM
Are the hex codes for colors in a jpg the same codes as used in html? abefroman Linux - Security 3 07-31-2005 03:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration