编译静态链接静态库的共享对象时遇到了很多问题.此问题仅出现在x84_64平台上.在x86_32上进行相同的编译工作时,我没有任何问题.
也许这是一个特定于操作系统的GCC配置,但我的研究表明它是如何在x86_64平台上运行GCC的.无论如何,我在Ubuntu 10.04 x86_64上使用gcc 4.4.3.
问题是如何解决的?...确保使用-fPIC编译所有静态库依赖项.
问题1: -fpic和-fPIC之间有什么区别(显然-fPIC会在x86上生成更多指令)?为什么后一种类型在x86_64上下文中更相关?
问题2:我的假设是,当您链接静态代码时,您在链接时将函数硬连接到二进制文件中,为什么它需要"位置无关代码"机制提供的间接级别?
问题3:现在如果x86不需要-fpic/-fPIC来链接共享对象与静态存档,为什么在x86_64中需要它?
问题4:即使需要,为什么不隐式提供?我认为突破性变化应该是一个很大的禁忌
gcc compilation dynamic-linking gnu-toolchain static-linking
我正在运行Mac OS X 10.5.8并希望使用GCC 4.1.2编译目标CentOS 5.3.我怎么能:
任何帮助是极大的赞赏!
我正在使用本教程构建ios工具链.当我运行命令make ENABLE_OPTIMIZED = 1时,我得到了这个输出.
llvm[0]: Reconfiguring with /home/connor/llvm-svn/configure
config.status: creating Makefile.config
config.status: creating llvm.spec
config.status: creating docs/doxygen.cfg
config.status: creating tools/llvm-config/llvm-config.in
config.status: creating include/llvm/Config/config.h
config.status: creating include/llvm/Support/DataTypes.h
config.status: include/llvm/Support/DataTypes.h is unchanged
config.status: creating include/llvm/ADT/hash_map
config.status: include/llvm/ADT/hash_map is unchanged
config.status: creating include/llvm/ADT/hash_set
config.status: include/llvm/ADT/hash_set is unchanged
config.status: creating include/llvm/ADT/iterator
config.status: include/llvm/ADT/iterator is unchanged
config.status: executing setup commands
config.status: executing Makefile commands
config.status: executing Makefile.common commands
config.status: executing examples/Makefile commands
config.status: executing lib/Makefile commands
config.status: executing runtime/Makefile commands
config.status: executing test/Makefile …Run Code Online (Sandbox Code Playgroud) 一个类似的(描述性较差),职位是在这里.
我正在尝试使用Ubuntu上的最新版本推出自己的工具链,并希望在这里有足够的Linux社区,我可以在出现问题时获得有关某些问题的具体建议.
在大家的帮助下,我希望最终能够看到这一点.
几乎每个人都提到的" Crosstool " 首先是一点点(2006年)已经过时了," Crosstool-NG "似乎现在正在我的机器上携带火炬.我宁愿调试进程本身而不是脚本(这似乎需要我理解这个过程).
以下是我到目前为止工作的基本步骤; 目前我被困在尝试编译第一次通过GCC.
失败的地方......
它失败了,因为缺少包含"crti.o"的交叉编译库:
# ./gcc-4.4.1/configure --target=arm-linux --disable-thread --enable-langauges=c
/bin/bash ../../../gcc-4.4.1/libgcc/../mkinstalldirs .
/usr/src/gnu-4.4.1-build/./gcc/xgcc -B ........
/usr/local/arm-linux/bin/ld: crti.o No such file: No such file or directory
collect2: ld returned 1 exit status
make[2]: *** [libgcc_s.so] Error 1
make[2]: Leaving directory `/usr/src/gnu/gcc-4.4.1-build/arm-linux/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/usr/src/gnu/gcc-4.4.1-build'
make: *** [all] Error 2
Run Code Online (Sandbox Code Playgroud)
构建步骤
在"新配置"的Ubuntu 9.04安装中,以下是我到目前为止所做的步骤:
#New configuration of Ubuntu 9.04
sudo updatedb
sudo apt-get install build-essential subversion …Run Code Online (Sandbox Code Playgroud) 当我将libm等库与ld链接时,我需要删除lib前缀.如果文件不遵循此命名约定怎么办?除了重命名文件之外,有没有办法链接它?
当我之前问过这个时,我应该提到它特别是我所追求的轻量级 IDE,所以我不得不再问一个不同的问题.
不仅仅是文本编辑器的东西,重量轻,功能多样,适合与MinGW,GDB和Subversion一起提供的GCC草莓.我想要使用的东西是直接可用的,并且也很快关闭以保留我的所有工作.如果它不是免费或开源程序并不重要,重要的是它稳定且使用舒适.
也许试图让一个IDE用于C和Perl是错误的方法 - 导致一个解决方案不能处理一种语言或另一种语言以及专用IDE?
我可能做错了什么,做个新手.你能帮帮我吗?
我在C中编写了一个名为hello.c的简单Hello World程序,并运行以下命令:
gcc -S hello.c
Run Code Online (Sandbox Code Playgroud)
那产生了hello.s.然后我用GNU汇编程序使用该文件as:
as hello.s
Run Code Online (Sandbox Code Playgroud)
哪个产生了非可执行文件a.out,哪些仍然需要链接,我明白了吗?
我尝试通过使用链接它ld,如下所示:
ld a.out
Run Code Online (Sandbox Code Playgroud)
但是得到以下错误:
a.out: file not recognized: File truncated
Run Code Online (Sandbox Code Playgroud)
并ld删除我的文件.
这是一个x86 Ubuntu系统.我究竟做错了什么?非常感谢!
请参阅标签部分.
这个决定背后的理由是什么?合并是否会影响构建最新binutils和GDB的建议方式?(事实上当我检查binutils-2_25_1并跑步时make all && make install,我也得到了gdb.)
我正在尝试按照http://openrisc.net/toolchain-build.html上Fedora Virtual Box Image 提供的指南为OpenRISC构建GNU工具链.
我收到错误说
Configure: error: cannot run /bin/sh ../gcc-svn/config.sub
Run Code Online (Sandbox Code Playgroud)
当我尝试配置gcc时.
我是Linux新手.我在网上找不到任何解决方案.任何帮助解决这个问题的人都非常感谢.
在我的main.c程序中,我包含了这个库:
#include "coap_api.h"
Run Code Online (Sandbox Code Playgroud)
这也包括在内
Properties -> C/C++ Build -> Settings -> Cross ARM GNU Assembler -> Includes
和
Properties -> C/C++ Build -> Settings -> Cross ARM C Compiler -> Includes
构建项目我收到此错误:
./src/main.o: In function `main':
/Users/joanet/Development/Embedded/eclipseWS/EHAL-master/ARM/Nordic/nRF51/ipv6_coap_server/Release/../src/main.c:708: undefined reference to `coap_init'
Run Code Online (Sandbox Code Playgroud)
我在另一篇文章中读到我必须链接库(http://whatwouldnickdo.com/wordpress/328/eclipse-cdt-and-linux-libraries/)
我试图添加名称的库,coap_api但我不工作
lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld: cannot find -lcoap_api
Run Code Online (Sandbox Code Playgroud)
在编译中包含coap目录:
arm-none-eabi-gcc -mcpu=cortex-m0 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -g -DBLE_STACK_SUPPORT_REQD -DNRF51 -D__CORTEX_M0 -DBOARD_PCA10028 -DSOFTDEVICE_PRESENT -DS110 -I/Users/nullpointer/Development/Embedded/eclipseWS/EHAL-master-Hoan/ARM/Nordic/nRF51/ipv6_coap_server/bsp -I/Users/nullpointer/Development/Embedded/eclipseWS/EHAL-master-Hoan/ARM/Nordic/nRF51/nrf51_sdk/components/iot/ipv6_stack/pbuffer -I"/Users/nullpointer/Development/Embedded/eclipseWS/EHAL-master-Hoan/ARM/Nordic/nRF51/nrf51_sdk/components/libraries/util/" -I"/Users/nullpointer/Development/Embedded/eclipseWS/EHAL-master-Hoan/ARM/Nordic/nRF51/nrf51_sdk/components/drivers_nrf/hal/" -I"/Users/nullpointer/Development/Embedded/eclipseWS/EHAL-master-Hoan/ARM/Nordic/nRF51/../../../ARM/CMSIS/CMSIS/Include/" -I"/Users/nullpointer/Development/Embedded/eclipseWS/EHAL-master-Hoan/ARM/Nordic/nRF51/../../../ARM/Nordic/nRF51/CMSIS/include/" -I"/Users/nullpointer/Development/Embedded/eclipseWS/EHAL-master-Hoan/ARM/Nordic/nRF51/nrf51_sdk/components/softdevice/s110/headers/" -I"/Users/nullpointer/Development/Embedded/eclipseWS/EHAL-master-Hoan/ARM/Nordic/nRF51/nrf51_sdk/components/ble/common/" -I"/Users/nullpointer/Development/Embedded/eclipseWS/EHAL-master-Hoan/ARM/Nordic/nRF51/nrf51_sdk/components/ble/ble_services/ble_bas/" -I"/Users/nullpointer/Development/Embedded/eclipseWS/EHAL-master-Hoan/ARM/Nordic/nRF51/nrf51_sdk/components/ble/ble_services/ble_dis/" …Run Code Online (Sandbox Code Playgroud)