LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-10-2020, 01:30 AM   #1
Paczki
LQ Newbie
 
Registered: Dec 2020
Location: australia
Distribution: Debian 10 (for apache)
Posts: 4

Rep: Reputation: Disabled
When compiling code with make, where does the compiled result go?


When I run “make” on source code, where do the compiled files go?

Thanks.
 
Old 12-10-2020, 02:29 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
That depends on the Makefile. If no Makefile exists, I believe the result is in the current directory.

EDIT: You may benefit from the introduction to makefiles in the GNU Make manual.

Last edited by berndbausch; 12-10-2020 at 02:33 AM.
 
4 members found this post helpful.
Old 12-10-2020, 02:43 AM   #3
Paczki
LQ Newbie
 
Registered: Dec 2020
Location: australia
Distribution: Debian 10 (for apache)
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thank you.
 
Old 12-10-2020, 06:55 AM   #4
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
That depends on the Makefile. If no Makefile exists, I believe the result is in the current directory.
If no makefile exists, make won't run like that. But the choices are never so numerous. Either the new binary is in the current directory or in one of the sub-directories. Most of the time, in my experience, there is "bin". If not, the binary may be produced right beside the source-files in "src". There are cases, where platform-specific subdirectories should be scrutinized. I have also one package that allows Gnu-Make or CMake and drops the binary in the pertinently named sub-directory.

Searching *all these* and even more, is not an immensly long process. Human logic applies in pratically all packages that I compile.., even my own.

Cheerio

P.S.: when working in the w3m browser the edit button below my post is labelled "Edit Mess". How did you know me that well...

Last edited by Michael Uplawski; 12-10-2020 at 06:57 AM.
 
Old 12-10-2020, 06:59 AM   #5
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,694

Rep: Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716
Check your source for README and INSTALL files. They often have the detail you are looking for.

If you have been doing this for a long time, you can read the Makefile directly (or the config file used to create the Makefile, if it exists.)
 
1 members found this post helpful.
Old 12-10-2020, 07:37 AM   #6
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Michael Uplawski View Post
If no makefile exists, make won't run like that.
It will:
Code:
$ ls
hi.c
$ make hi
cc     hi.c   -o hi
hi.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 main(){printf("hi!\n");}
 ^
... warning messages ...
$ ./hi
hi!
$
 
2 members found this post helpful.
Old 12-10-2020, 03:22 PM   #7
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
It will:
It does. I stand corrected. And it calls the right compiler, gcc or g++.
 
Old 12-11-2020, 04:40 AM   #8
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,911

Rep: Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030
Quote:
Originally Posted by Michael Uplawski View Post
It does. I stand corrected. And it calls the right compiler, gcc or g++.
Yes, as long as you're not compiling via intermediate .o files: where it will assume C rather than C++ for the link.
Code:
$ ls
"example1.c"  "example2.cc"
$ make example1.o example1
cc    -c -o example1.o example1.c
cc   example1.o   -o example1
$ make example2.o example2
g++    -c -o example2.o example2.cc
cc   example2.o   -o example2
/usr/bin/ld: example2.o: warning: relocation against `_ZSt4cout' in read-only section `.text'
/usr/bin/ld: example2.o: in function `main':
example2.cc:(.text+0xe): undefined reference to `std::cout'
/usr/bin/ld: example2.cc:(.text+0x13): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: example2.cc:(.text+0x1d): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/usr/bin/ld: example2.cc:(.text+0x28): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/usr/bin/ld: example2.o: in function `__static_initialization_and_destruction_0(int, int)':
example2.cc:(.text+0x58): undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: example2.cc:(.text+0x6d): undefined reference to `std::ios_base::Init::~Init()'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [<builtin>: example2] Error 1
$ rm example2.o && make example2
g++     example2.cc   -o example2
$ 

Last edited by GazL; 12-11-2020 at 04:43 AM.
 
1 members found this post helpful.
Old 12-11-2020, 05:05 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,967

Rep: Reputation: 7333Reputation: 7333Reputation: 7333Reputation: 7333Reputation: 7333Reputation: 7333Reputation: 7333Reputation: 7333Reputation: 7333Reputation: 7333Reputation: 7333
Quote:
Originally Posted by Michael Uplawski View Post
It does. I stand corrected. And it calls the right compiler, gcc or g++.
make comes with predefined (default) rules. If that works no makefile needed.
But those default rules are often not really suitable for real work.
 
3 members found this post helpful.
Old 12-11-2020, 02:46 PM   #10
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
make comes with predefined (default) rules. If that works no makefile needed.
But those default rules are often not really suitable for real work.
As I learned this yesterday, only, I could not come up with possible – so called “serious” – uses other than tiny quick examples.
 
Old 12-12-2020, 10:22 AM   #11
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: Slackware®
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Moderator Response

Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 12-12-2020, 10:33 AM   #12
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,873
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Is there any unanswered questions?
 
Old 12-13-2020, 07:24 AM   #13
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
Is there any unanswered questions?
Maybe not, but someone who finds the thread later can be comforted and maybe less alienated by a lax handling of the forum conventions. All is theory; you have to want and I am always glad to see people want something.
 
1 members found this post helpful.
  


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
result of : top -o COMMAND ? explain the result please mike1047 Linux - Newbie 2 10-31-2019 09:20 AM
result of : top -o COMMAND ? explain the result please mike1047 Linux - Newbie 3 10-31-2019 09:18 AM
am not getting any result when am using 'if', without getting result for below script alavala53 Linux - General 3 10-25-2012 06:00 PM
[SOLVED] Grep for the result of a command within the result of another command jasonws Programming 6 11-18-2010 02:39 PM

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

All times are GMT -5. The time now is 03:52 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