求助: gdb 调试错误 init.c no such file or directory(已经解决)

软件和网站开发以及相关技术探讨
回复
husince
帖子: 6
注册时间: 2007-12-22 19:38

求助: gdb 调试错误 init.c no such file or directory(已经解决)

#1

帖子 husince » 2009-09-01 21:58

大家好,我是新手。刚刚开始学习linux下C++的编程。
在学习过程中遇到了以下问题,请帮忙看看,多谢了。
我的程序很简单,是在网上找到的,代码如下:

文件一: main.cpp
#include "mytool1.h"
#include "mytool2.h"
#include "stdio.h"

int main(int argc, char **argv) {
mytool1_print("hello");
mytool2_print("hello,husince");
}

文件二: mytool1.cpp
#include "mytool1.h"
#include "stdio.h"

void mytool1_print(char *print_str){
printf("This is mytool1 print %s\n",print_str);
}

文件三:mytool1.h
#ifndef _MYTOOL_1_H
#define _MYTOOL_1_H

void mytool1_print(char *print_str);

#endif

文件四:mytool2.cpp
#include "mytool2.h"
#include "stdio.h"

void mytool2_print(char *print_str){
printf("This is mytool2 print %s\n", print_str);
}

文件五:mytool2.h
#ifndef _MYTOOL_2_H
#define _MYTOOL_2_H

void mytool2_print(char *print_str);

#endif

以上是源文件, 还写了个makefile:
x : main.o mytool1.o mytool2.o
g++ -g -o x $^
main.o : main.cpp mytool1.h mytool2.h
g++ -g -c main.cpp
mytoo11.o : mytool1.cpp mytool1.h
g++ -g -c mytool1.cpp
mytool2.o : mytool2.cpp mytool2.h
g++ -g -c mytool2.cpp
clean :
rm x main.o mytool1.o mytool2.o

现在的问题
1. make 运行后会有错误提示,虽然仍然能够生成./x可执行文件。
错误提示是:
g++ -c -o mytool1.o mytool1.cpp
In file included from mytool1.cpp:21:
mytool1.h:25:7: warning: no newline at end of file
mytool1.cpp:26:2: warning: no newline at end of file
g++ -g -o x main.o mytool1.o mytool2.o
main.o : main.cpp mytool1.h mytool2.h
make: main.o: Command not found
make: *** [x] Error 127


2.运行 gdb x 后,进入<gdb>下后,无法用list命令查看源文件。
错误提示是:1 init.c: no such file or directory
网上查下来说编译的时候要加-g, 可是大家看到了,我已经每个都加了。

3.我希望能够在Kdevelop环境下,对这个工程引入然后断点调试。工程的导入倒是没什么问题,但是怎么利用Kdevelop内置的调试器对这样的工程进行断点调试呢?因为不是automake的工程, 没有configure option之类的可以选择。如果有办法能在Kdevelop里面用gdb调试也可以,请那位大侠告知如何设置debugger等的选项。

三个问题随便哪个能够帮我解惑都好,多谢多谢大家了!
上次由 husince 在 2009-09-02 15:36,总共编辑 1 次。
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

Re: 求助: gdb 调试错误 init.c no such file or directory

#2

帖子 BigSnake.NET » 2009-09-01 22:19

Makefile 写错了, 没链接完整
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
husince
帖子: 6
注册时间: 2007-12-22 19:38

Re: 求助: gdb 调试错误 init.c no such file or directory

#3

帖子 husince » 2009-09-01 22:27

非常感谢您的回复,能不能说的具体一点?
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

Re: 求助: gdb 调试错误 init.c no such file or directory

#4

帖子 BigSnake.NET » 2009-09-01 22:32

husince 写了:非常感谢您的回复,能不能说的具体一点?
你检查一下 Makefile , 看 tab 什么的对不对..
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
husince
帖子: 6
注册时间: 2007-12-22 19:38

Re: 求助: gdb 调试错误 init.c no such file or directory

#5

帖子 husince » 2009-09-01 22:33

tab是除了第一行,其余每行前面都有一个的
husince
帖子: 6
注册时间: 2007-12-22 19:38

Re: 求助: gdb 调试错误 init.c no such file or directory

#6

帖子 husince » 2009-09-02 11:05

谢谢,我已经找到错误了。原来我没搞清楚tab是加在命令行,而不能加在依赖行的。
现在问题已经都解决了。
回复