所以我正在通过斯坦福大学的CS107课程的作业,我无法通过编译未完成的程序(项目文件和原始的makefile可以found on the course page,我工作的分配4 RSS)为32位架构编译和链接一个C程序
经过大量的研究,我认为的问题是我使用的是64位架构(的Mac OS 10.6)和预编译库代码GCC在assn-4-rss-news-search-lib/linux
下是针对32位架构的。我尝试设置gcc使用i386和-m36,但没有工作,我只是猜测。
因此,这里的输出我得到的,当我运行make
:
gcc -g -Wall -std=gnu99 -Wno-unused-function -c -o rss-news-search.o rss-news-search.c
gcc rss-news-search.o -g -Wall -std=gnu99 -Wno-unused-function -g -lnsl -lrssnews -L/Users/derp/Documents/OCW/CS107/Work/programming4/assn-4-rss-news-search-lib/linux -o rss-news-search
ld: library not found for -lnsl
collect2: ld returned 1 exit status
make: *** [rss-news-search] Error 1
这里的输出我得到的,当我删除-lnsl
,其中结构差异提到:
gcc -g -Wall -std=gnu99 -Wno-unused-function -c -o rss-news-search.o rss-news-search.c
gcc rss-news-search.o -g -Wall -std=gnu99 -Wno-unused-function -g -lrssnews -L/Users/derp/Documents/OCW/CS107/Work/programming4/assn-4-rss-news-search-lib/linux -o rss-news-search
ld: warning: in /Users/derp/Documents/OCW/CS107/Work/programming4/assn-4-rss-news-search-lib/linux/librssnews.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols:
"_URLConnectionDispose", referenced from:
_ProcessFeed in rss-news-search.o
_ParseArticle in rss-news-search.o
... several more undefined symbols mentioned ...
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [rss-news-search] Error 1
所以我要求关于我能做些什么来解决这个问题的任何想法。我已经花了好几个小时来调整设置,并且Google一直没有成功。
你能编译c代码期吗?尝试在c中编写hello world并尝试编译。我知道我在OSX上遇到了gcc和stdc lib的一些问题,所以请确保它不是这样。 – themaestro 2011-03-02 04:41:54
如果安装了相应的工具和后端,请使用'-m32'。但这里似乎问题并不直接相关,从错误信息这一问题...... – 0xC0000022L 2011-03-02 04:44:56
啊,我实际写一吨的代码下这门课程,但显然分配4和6是麻烦点。通常情况下,Makefiles提供并且工作正常,但是它们是为斯坦福Linux/Solaris机器针对真正的参加学生而编写的。 – theabraham 2011-03-02 04:45:52