Articles of gcc

使剥离未使用的文件

在我目前的项目中,存在超过200MB的C文件。 在制作目标时,我可以看到只有<100MB用于创build二进制文件。 在创build目标时如何识别什么是文件。 所以,我们可以剥离它,使代码库更加圆滑。 如何在编译时识别为目标创build的文件列表?

GLM和primefacesg ++ 4.8

我前几天从Windows切换到Linux,并且非常喜欢它。 不幸的是我有移植我的项目的问题。 在那里,我使用GLM进行向量计算和primefaces一起。 一切工作正常在Visual Studio上。 我遇到的第一个问题是,出于某种原因,只要包含atomic头,g ++ 4.6就给了我一个undefined referece to 。 然后我切换到g ++ 4.8,问题就没有了。 但是现在,只要我使用一个像这样的向量的primefaces: atomic<vec3> ,我就会遇到一个新的问题。 这就是g ++所说的: /usr/include/c++/4.8/atomic|167|error: function 'std::atomic<_Tp>::atomic() [with _Tp = glm::detail::tvec3<float>]' defaulted on its first declaration with an exception-specification that differs from the implicit declaration 'std::atomic<glm::detail::tvec3<float> >::atomic()'| 我不知道如何解决这个问题。 我想尝试g ++ 4.9,但我甚至不知道如何得到这个。 这是一个简单的代码,在我的机器上崩溃: #include <iostream> #include <glm.hpp> #include <atomic> using namespace […]

用gcc静态编译错误

我想编译下面的代码: #include<stdio.h> void func() { printf("In function\n"); return ; } int main() { printf("In mains\n"); func(); return 0; } 使用gcc -static -o try try.c但得到以下错误: /usr/bin/ld: error: hidden symbol '__ehdr_start' is not defined locally /usr/bin/ld: error: hidden symbol '__ehdr_start' is not defined locally /usr/bin/ld: error: hidden symbol '__ehdr_start' is not defined locally /usr/bin/ld: error: hidden symbol […]

使用GCC和GDB的Ubuntu上的QT Creator – debuggingC ++ – 更详细的分段错误消息

我在Linux上工作比较新,所以我可能会忽略一些简单的东西。 在Windows上,如果我的程序导致分段错误,我已经习惯了一些有用的信息popup。 有什么影响: Access violation reading/writing/executing memory at address 0x**** , Stack overflow等 在通过QT Creator进行Linuxdebugging时,我所得到的是: The inferior stopped because it received a signal from the Operating System. Signal name : SIGSEGV Signal meaning : Segmentation fault 有没有办法让这些消息给出相同的信息,在他们的Windows相对应,或至less是故障的types(内存违规,堆栈溢出等)? 我当然可以使用GDB来debugging程序,但是这个popup窗口通常会让我很快了解问题所在,而不是在崩溃站点周围进行挖掘。

什么时候执行得到分配的内核版本?

Linux file命令提供有关可执行file信息,例如: “/ home / foo:为GNU / Linux 2.6.9dynamic链接(使用共享库)的ELF 32位LSB可执行文件,Intel 80386,版本1(SYSV),剥离” 我特别感兴趣的是“输出的GNU / Linux 2.6.9”部分。 什么决定? 鉴于我有两台机器,都安装了gcc 4.6,但有一台机器是2.6.9 Linux内核,另一台机器是3.2.0 Linux内核。 如果我在2.6.9机器上编译.o或.a文件,然后将其转换到3.2.0机器,我甚至可以将它链接到内置的可执行文件中吗? 如果我把它连接起来,我的可执行文件的内核版本是否仍然是3.2.0?

为什么不能在/etc/ld.so.conf中findpath的库?

我想将/opt/vertica/lib64到系统库path中,所以我执行以下步骤: (1)将/opt/vertica/lib64到/etc/ld.so.conf ,并运行ldconfig , (2)检查: bash# ldconfig -p | grep vertica libverticaodbc.so (libc6,x86-64) => /opt/vertica/lib64/libverticaodbc.so …… 但是当我运行“ ld -lverticaodbc –verbose ”命令时: ================================================== attempt to open /usr/x86_64-redhat-linux/lib64/libverticaodbc.so failed attempt to open /usr/x86_64-redhat-linux/lib64/libverticaodbc.a failed attempt to open /usr/local/lib64/libverticaodbc.so failed attempt to open /usr/local/lib64/libverticaodbc.a failed attempt to open /lib64/libverticaodbc.so failed attempt to open /lib64/libverticaodbc.a failed attempt to open […]

跟踪未定义的参考

我怎样才能跟踪一个未定义的参考与gcc ld ? 我已经尝试了-trace-symbol=some_ref , -trace-symbol=some_ref但是它并没有显示符号被调用的地方。 我想获得某种调用堆栈,显示为什么符号被调用的第一个地方。 所以简而言之,我需要从顶层向下追踪那个符号的所有引用。 有没有这个标志?

gsl:make文件不能链接,/ usr / bin / ld:找不到-lgsl

我在linux服务器上出现以下错误 gcc -m64 -O3 /export/projects/EL/mlml21/gsl-1.16/.libs/libgsl.a /export/projects/EL/mlml21/gsl-1.16/cblas/.libs/libgslcblas.a -I/export/projects/EL/mlml21/gsl-1.16 -std=c99 -o em em.c data.c prob_functions.c -lgsl -lgslcblas -lm / usr / bin / ld:找不到-lgsl collect2: ld returned 1 exit status make :*** [em]错误1' 通过运行下面的makefile default: em em_mex clean:`rm -f * .o em CBLAS_LIB=/export/projects/EL/mlml21/gsl-1.16/cblas/.libs .libs GSL_LIB = / export / projects / EL / mlml21 / gsl-1.16 / […]

无法在读取模式下打开消息队列(mq_open())

我有一个程序创build一个消息队列,并发送一个消息(与mq_send() )到这个队列。 然后我尝试打开相同的消息队列来读取另一个进程的消息。 但是mq_open()返回-1。 open_and_write_MQ.c #include <stdio.h> #include <mqueue.h> #include <stdlib.h> #include <string.h> #define LEN 50 int main(int argc, char * argv[]) { struct mq_attr attr; mqd_t fd; char buff[LEN]; attr.mq_flags = 0; attr.mq_maxmsg = 10; attr.mq_msgsize = LEN; attr.mq_curmsgs = 0; memset(buff,0,LEN); strcpy(buff,"This is just a test message"); if(argc < 2) { printf("\nPlease enter […]

ARM-GCC在Fedora 21下生成错误

我试图在Fedora 21中为ARM构buildGCC,但4.6.4和4.9.2失败,出现同样的错误: checking dynamic linker characteristics… configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES. Makefile:8200: recipe for target 'configure-zlib' failed 我遵循这个指南: http : //www.kunen.org/uC/gnu_tool.html 不明白,我做错了什么? PS configure命令: ../../src/gcc-4.9.2/configure –target=arm-none-eabi –prefix=$MYTOOLS –enable-interwork –enable-multilib –enable-languages="c,c++" –with-newlib –with-headers=../../src/newlib-1.20.0/newlib/libc/include/