libf2c-3.3.2-1.i386.rpm libstdc++-devel-3.3.2-1.i386.rpm glibc-kernheaders-2.4-8.36.i386.rpm glibc-headers-2.3.2-101.i386.rpm glibc-devel-2.3.2-101.i386.rpm gcc-objc-3.3.2-1.i386.rpm binutils-2.14.90.0.6-3.i386.rpm gcc-3.3.2-1.i386.rpm gcc-c++-3.3.2-1.i386.rpm automake14-1.4p6-7.noarch.rpm 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/110700/showart_2156255.html
by superzgc - Linux文档专区 - 2010-01-21 15:39:26 阅读(952) 回复(0)
我在做项目的时候发现gcc在对多个lib或.o连接的时候会受引用顺序影响。 比如: gcc main.o foo1.a foo2.a -o myapp gcc main.o foo2.a foo1.a -o myapp 编译结果会不一样。我怀疑是在不同库之间的函数调用的关系引起的,并 在gcc的Using the GNU Compiler Collection中看到有这些解释: the linker searches and processes libraries and object files in the order they are specified. Thus, ‘foo.o -lz bar.o’ searches lib...
我在做项目的时候发现gcc在对多个lib或.o连接的时候会受引用顺序影响。 比如: gcc main.o foo1.a foo2.a -o myapp gcc main.o foo2.a foo1.a -o myapp 编译结果会不一样。我怀疑是在不同库之间的函数调用的关系引起的,并 在gcc的Using the GNU Compiler Collection中看到有这些解释: the linker searches and processes libraries and object files in the order they are specified. Thus, ‘foo.o -lz bar.o’ searches lib...
gcc -Dgdz -D_DEBUG -I -L. -L/usr/include -lpthread -lload -lstdc++ \ -g \ -c main.cpp \ -o main \ -static \ -L. -lmagi gcc: -lpthread: linker input file unused since linking not done gcc: -lload: linker input file unused since linking not done gcc: -lstdc++: linker input file unused since linking not done gcc: -lmagi: linker input file unused since linking not done 当前目录下的libmagi.a找不...
其中main.cpp中有main函数,a.cpp中需要用到xxx库 g++ -o a.out main.cpp -lxxx a.cpp b.cpp 这样编译不过,报错a.cpp中某行有undefined reference(xxx中的)。 把顺序调整一下: g++ -o a.out main.cpp a.cpp -lxxx b.cpp 能编过了,但是运行时coredump(main中调用了xxx中的一个空test函数,如果不掉用就不会coredump),怀疑是编译时链接地址弄错了 请教编译的顺序有什么讲究么?多谢指教。
将多个.o文件链接成可执行文件的时候。如果链接的顺序不对,会产生错误。 《An introduction of gcc》里面有下面一段话: On Unix-like systems, the traditional behavior of compilers and linkers is to search for external functions from left to right in the object files specified on the command line. This means that the object file which contains the definition of a function should appear after any files w...
最近在用gcc编译,之后ld连接时,发现生成的bin无法执行,狂搜了一阵。 现问题已经解决,简化阐述如下: 1 源文件hello.c #include int main(int argc, char *argv[]) { printf("hello\n"); return 0; } 2 gcc编译 gcc hello.c -o hello 然后运行 ./hello 输出结果 hello 3 gcc编译,ld连接 gcc -c hello.c -o hello.o ld -o hello hello.o 此时会出现问题,生成的hello文件无法执行...
有3个文件,helper.c helper.h howdy.c ,代码如下:
helper.h
void msg(void) ;
void a(void) ;
helper.c
#include "helper.h"
#include
gcc 中,调用者保存的局部变量的入栈顺序跟什么有关阿?是顺序?逆序? 《深入理解计算机系统》书上有的例子显示是逆序的,可是gcc编译产生的是顺序的? 我知道函数参数是按逆序入栈的 。
发现gcc在连接时会丢目标文件 比如有两个c文件 a.c和b.c 经过编译后生成a.o和b.o 现在需要将两个目标文件连接成一个exe文件。 但如果b中的函数没有被a中的函数调用过,连接后的exe文件没有b.o的代码。 必须在a中增加调用b中的函数才能将a.o和b.o连接在一起。 请教高手,如何强制gcc连接所有的目标文件,而不考虑目标文件的调用关系。