I am trying to do something rather simple, but don't understand why I am getting an error. I have a Makefile I will include so you can see what is going on. But when I step through the program I get libc-start.c: No such file or directory. Is there a way to handle this in the Makefile or avoid this?
Makefile
# makefile to build a program
# program depends on components: name and main
myname: main.o name.o
g++ -g -ggdb main.o name.o -o myname
# name.cpp has it's own header file
name.o: name.cpp name.h
g++ -c -g -ggdb name.cpp
# main.cpp also uses the header file name.h
main.o: main.cpp name.h
g++ -c -g -ggdb main.cpp
clean:
/bin/rm -f myname *.o
main.cpp
#include <iostream>
#include <string>
using namespace std;
#include "name.h"
int main () {
name myName;
myName.SetLast(LAST);
myName.SetMiddle(MI);
myName.SetFirst(FIRST);
cout <<"My name is: ";
myName.PrintFirst();
myName.PrintMiddle();
myName.PrintLast();
return 0;
}
name.cpp
#include <iostream>
#include <string>
using namespace std;
#include "name.h"
void name::GetFirst(string str) {
str=first;
}
void name::SetFirst(string str) {
first=str;
}
void name::GetMiddle(string str) {
str=middle;
}
void name::SetMiddle(string str) {
middle=str;
}
void name::GetLast(string str) {
str=last;
}
void name::SetLast(string str) {
last=str;
}
void name::PrintLast() {
cout << last << "\n";
}
void name::PrintMiddle() {
cout << middle;
}
void name::PrintFirst() {
cout << first;
}
name.h
#define LAST "Tank-Engine"
#define MI "T. "
#define FIRST "Thomas "
class name {
private:
string first;
string middle;
string last;
public:
void SetFirst(string str);
void GetFirst(string str);
void SetMiddle(string str);
void GetMiddle(string str);
void SetLast(string str);
void GetLast(string str);
void PrintLast();
void PrintMiddle();
void PrintFirst();
};
gdb error when stepping through
name::PrintLast (this=0x7fffffffe4a0) at name.cpp:31
31 cout << last << "\n";
(gdb) s
My name is: Thomas T. Tank-Engine
32 }
(gdb) s
main () at main.cpp:18
18 return 0;
(gdb) s
name::~name (this=0x7fffffffe4a0, __in_chrg=<optimized out>) at name.h:5
5 class name {
(gdb) s
main () at main.cpp:19
19 }
(gdb) s
__libc_start_main (main=0x400b86 <main()>, argc=1, argv=0x7fffffffe5b8, init=<optimized out>,
fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe5a8) at libc-start.c:323
323 libc-start.c: No such file or directory.
(gdb) s
__GI_exit (status=0) at exit.c:104
104 exit.c: No such file or directory.
(gdb) s
103 in exit.c
(gdb) s
104 in exit.c
(gdb) s
__run_exit_handlers (status=0, listp=0x7ffff78ae698 <__exit_funcs>,
run_list_atexit=run_list_atexit@entry=true) at exit.c:35
35 in exit.c
(gdb)
CFLAGSandCXXFLAGS:-g3 -O0.-g3will include symbolic defines, and-O0may help with<optimized out>. Also see Compile with -g option but “Single stepping until exit from function main, which has no line number information”. The cited question says to update GDB. Have you runapt-get update && apt-get dist-upgraderecently?