Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to run a file off the Internet with GNU Debugger. So I download the tar.gz file off the Internet, and I extract it and compile it. Then in the directory of the compiled source, I type: gdb -q ./whatever.c
where "whatever.c" is the name of the file I want to run
However, when I do this gdb doesn't have access to the source code, so I cant do much with it. So is there any way I can make it have access to the source code? Please be specific, I'm not very good with this kind of thing.
Okay. So what changes do I need to make in the makefile so that it compiles that way? Do I just need add the line "make CFLAGS=-g" somewhere in the makefile?
If there is a line containing the variable CFLAGS, then simply add the -g flag to it. If the line doesn't exist, then add the whole thing (i.e. add the line"CFLAGS=-g").
What do you mean by "it failed"? Please post error messages verbatim. I'd google for makefile tutorials. Otherwise, post the makefile here and what exactly you're having problems with.
There were no variables named CFLAGS, so I added the line "CFLAGS=-g" to the makefile. It compiled without any errors. But when I ran it with GDB it still didn't let me look at the source code. So basically adding "CFLAGS=-g" didn't change anything. I even tried it on many different files off the Internet, and this didn't work with any of them.
The line "CFLAGS=-g" itself doesn't do anything, the makefile has to be setup for it. Since your makefile didn't include that variable, adding the line will do nothing. Without the CFLAGS variable, you might as well just find the line where the makefile is calling gcc and add in "-g" yourself.
Can you post the makefile (use CODE tags), or at least tell us what program you are trying to compile?
A question for perort: the tar.gz file that you compiled; does the compile begin with the ./configure step? If yes, then you can edit the makefile in the prefered method, by setting the appropriate options to ./configure.
Try "./configure --with-gdb" (sans quotes), then make and install.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.