小编Mat*_*gan的帖子

使用gcc --shared -m64 -Wl, - whole-archive ./*.a从静态库创建动态库

我收到这组gcc错误,我似乎无法从谷歌或手册页得到答案.任何洞察这些意味着什么或从哪里开始寻找?

这是makefile中的行:

#After building several otehr bits of code into static libraries
...
# Grand finally link all the object files into one
        gcc --shared  \
        -m64 \
        -Wl,--whole-archive ./release64/*.a \
        -o ./release64/libMYLIB.so.1.0
        ln -sf libArcGIS.so.1.0 ./release64/libMYLIB.so
        ln -sf libArcGIS.so.1.0 ./release64/libMYLIB.so.1
Run Code Online (Sandbox Code Playgroud)

我得到了以下错误(还有更多我采取了前n只是为了给出一个想法:

/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_muldi3.o): In function `__multi3':
(.text+0x0): multiple definition of `__multi3'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_muldi3.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_negdi2.o): In function `__negti2':
(.text+0x0): multiple definition of `__negti2'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_negdi2.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_lshrdi3.o): In function `__lshrti3':
(.text+0x0): multiple definition of `__lshrti3'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_lshrdi3.o):(.text+0x0): first defined …
Run Code Online (Sandbox Code Playgroud)

gcc static-libraries dynamic-library

4
推荐指数
2
解决办法
2125
查看次数

For GNU Makefile中的循环 - 将所有目标文件收集到一个Mutliple目录中的变量中

我希望通过这个小脚本总结出我想要实现的目标.

DIRS = dir1 dir2 dir3 dir4 ...
OBJS =

all: GENERATE_OBJECT_FILES

GENERATE_OBJECT_FILES: 
        for curr_dir in $(DIRS); \
        do \
                $(join $(OBJS), `ls $${curr_dir}/*.o`); \
        done

        echo $(OBJS);
Run Code Online (Sandbox Code Playgroud)

如何使用Makefile中的脚本完成此操作?

makefile gnu-make

4
推荐指数
2
解决办法
1万
查看次数

如何:链接列表的深层复制

我在用C编写的程序遇到了一些问题,而且我已经超越了我的知识.总之,我需要将链接列表从一个列表深层复制到另一个列表.这些列表中包含malloc数据,我需要保留所有数据,而不需要指针指向相同的信息.

我只发布了我认为相关的代码.如果我遗漏了任何重要的背景信息,请告诉我.

这是代码:

matrix.h

typedef struct matrix {
        char *name;
        int R;
        int C;
        int dim;
        void (*concat_matrices)( struct matrix *A, struct matrix *B, struct matrix *ret );
} Matrix;

void concat_matrices( Matrix *A, Matrix *B, Matrix *ret ) {
        int L1 = strlen( A->name );
        int L2 = strlen( B->name );
        int len = L1 + L2;
        char *Ap = (char*)malloc(L1*sizeof(char)); strcpy(Ap,A->name);
        char *Bp = (char*)malloc(L2*sizeof(char )); strcpy(Bp,B->name);
        char *c = (char*)malloc(sizeof(char)*(len + 2));
        c[0] = '('; strcat(c, Ap); …
Run Code Online (Sandbox Code Playgroud)

c

3
推荐指数
1
解决办法
2778
查看次数

gcc真的知道如何输出NASM Assembly

所以我有一个简单的C程序循环传递给main的args然后返回:

#include <stdio.h>

int main(int argc, char *argv[])
{
    int i;
    for(i = 0; i < argc; ++i) {
        fprintf(stdout, "%s\n", argv[i]);
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我想看看gcc如何用NASM格式写出程序集.我正在查看.asm文件中的输出,并注意到语法是TASM.下面是make文件和gcc的输出.我做错了还是gcc没有输出真正的NASM语法?

all: main

main: main.o
        ld -o main main.o

main.o : main.c
        gcc -S -masm=intel -o main.asm main.c
        nasm -f elf -g -F stabs main.asm -l main.lst
Run Code Online (Sandbox Code Playgroud)

    .file   "main.c"
    .intel_syntax noprefix
    .section    .rodata
.LC0:
    .string "%s\n"
    .text
.globl main
    .type   main, @function
main:
    push    ebp
    mov ebp, esp
    and esp, -16
    sub esp, …
Run Code Online (Sandbox Code Playgroud)

gcc nasm tasm

3
推荐指数
1
解决办法
4152
查看次数

将 .org 指令与 .data 部分中的数据一起使用:与 ld 相关

在我努力了解如何使用 GNU binutils 使用 Gas构建简单的引导加载程序时,我遇到了一个问题,如何告诉链接器将数据放在使用 .org 推进位置计数器的文件中的位置同时将文件大小保持在 512 字节。我似乎找不到办法做到这一点。

尝试执行此操作的汇编程序是:

# Author: Matthew Hoggan
# Date Created: Tuesday, Mar 6, 2012

.code16                      # Tell assembler to work in 16 bit mode
.section .data
msg:                         # Message to be printed to the screen
  .asciz "hello, world"

.section .text
.globl _start                # Help linker find start of program
_start:
  xor  %ax,  %ax             # Zero out ax register (ah used to specify bios function to Video Services) 
  movw %ax,  %ds             # Since …
Run Code Online (Sandbox Code Playgroud)

linux gnu-assembler ld att

3
推荐指数
1
解决办法
1000
查看次数

C中的Bit Hack无法理解

我在接受采访时被问到这个问题,但仍无法弄清楚它的作用.有人可以解释它的作用以及它是如何做到的吗?

v = v - ((v >> 1) & (T)~(T)0/3);                           // temp
v = (v & (T)~(T)0/15*3) + ((v >> 2) & (T)~(T)0/15*3);      // temp
v = (v + (v >> 4)) & (T)~(T)0/255*15;                      // temp
c = (T)(v * ((T)~(T)0/255)) >> (sizeof(T) - 1) * CHAR_BIT; // count
Run Code Online (Sandbox Code Playgroud)

c bit-manipulation

3
推荐指数
1
解决办法
416
查看次数

Android:调用Context.startService()后未启动嵌套Intent服务

我的嵌套意图服务定义如下:

package com.my.package;

... // Bunch of imports

public class MyNotifier

    ... // Bunch of variables

    public class MissedCallIntentService extends IntentService {

        private static final String TAG = "MissedCallIntentService";

        public MissedCallIntentService() {
            super("MissedCallIntentService");
            Log.i(TAG, "Creating intent service.");
        }

        @Override
        public void onHandleIntent(Intent intent) {
            Log.i(TAG, "Handling intent service.");
        }
    }

    // Test my nested intent filter
    public MyNotifier(Context app) {
        mApp = app;
        Log.i(LOG_TAG, "Going to start intent service.");
        Intent intent = new Intent(mApp, MissedCallIntentService.class);
        mApp.startService(intent);
    }

    ... // Bunch …
Run Code Online (Sandbox Code Playgroud)

java xml android intentservice

3
推荐指数
1
解决办法
2102
查看次数

尝试了解二进制文件 (NASM) 输出的大小

我有这两个文件 myboot.asm 和 Theirboot.asm (分别列出):

;----------------------------------------------------------------------
; A Simple boot program that prints the string 'Hello World'
; Author: Matthew Hoggan 2012
;----------------------------------------------------------------------
Output db 'Hello',0x00            ; Output string for bios

org 0x7c00                              ; This is where BIOS loads the bootloader

entry:                                  ; Label to Signify entry to program
    jmp short begin                     ; Jump over the DOS boot record data

; --------------------------------------------
;  Boot program code begins here
; --------------------------------------------
begin:                                  ; Label to Signify entry to program
mov si, …
Run Code Online (Sandbox Code Playgroud)

linux nasm

2
推荐指数
1
解决办法
1231
查看次数

使用Automake确定Makefile.am中的体系结构

要查看我要执行的操作,请参见以下内容:

我的问题是如何在我的Makefile.am中有条件地设置AM_CPPFLAGS或my_lib_la_CPPFLAGS。这样在运行configure时是否设置了正确的CPPFLAGS?

目前,我正在做一些影响以下方面的事情:

lib_xml_wrapper_la_CPPFLAGS = -I../../

UNAME_S = $(shell uname -s)   
UNAME_P = $(shell uname -p)   
ifeq ($(UNAME_S),Linux)       
    lib_xml_wrapper_la_CPPFLAGS += -DLINUX
    ifeq ($(UNAME_P),x86_64)  
        lib_xml_wrapper_la_CPPFLAGS += -D AMD64
    endif
    ifeq ($(UNAME_P),x86_64)  
        lib_xml_wrapper_la_CPPFLAGS += -I../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include/
    endif
    ifneq ($(filter %86,$(UNAME_P)),)
        lib_xml_wrapper_la_CPPFLAGS += -I../../../external/xerces-c-3.1.1-x86-linux-gcc-3.4/include/
    endif
    ifneq ($(filter arm%,$(UNAME_P)),)
        lib_xml_wrapper_la_CPPFLAGS += 
    endif
endif
ifeq ($(UNAME_S),Darwin)
    lib_xml_wrapper_la_CPPFLAGS += -DOSX
    ifneq ($(filter %86,$(UNAME_P)),)
        lib_xml_wrapper_la_CPPFLAGS += -I../../../external/xerces-c-3.1.1-x86-macosx-gcc-3.4/include/
    endif
    ifneq ($(filter arm%,$(UNAME_P)),)
        lib_xml_wrapper_la_CPPFLAGS += 
    endif
endif
Run Code Online (Sandbox Code Playgroud)

这似乎在Makefile.am中不起作用。我收到以下错误:

xml_wrapper/Makefile.am:26: error: endif without if
xml_wrapper/Makefile.am:35: error: endif without if
automake: warnings …
Run Code Online (Sandbox Code Playgroud)

automake autotools computer-architecture

2
推荐指数
1
解决办法
1120
查看次数

QMatrix4x4模型视图投影OpenGL无法获取场景渲染

给定此顶点着色器:

attribute vec3 vertex;
uniform mat4 mvp;

void main() {
    gl_Position = mvp * vec4(vertex, 1.0);
}
Run Code Online (Sandbox Code Playgroud)

这个片段着色器:

void main() {
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
Run Code Online (Sandbox Code Playgroud)

mvp矩阵是标识或模型矩阵是缩放,旋转或转换变换时,哪个能够渲染下面的数据:

GLfloat values[] = {
    -1.0, -1.0, +0.0,
    +1.0, -1.0, +0.0,
    +0.0, +1.0, +0.0,
};
Run Code Online (Sandbox Code Playgroud)

为什么以下使用Qt QMatrix4x4::lookAtQMatrix4x4::perspective导致场景被渲染,好像没有对象?

QMatrix4x4 model;
QMatrix4x4 view;
view.lookAt(
  QVector3D(0.0, 0.0, 10.0), // Eye
  QVector3D(0.0, 0.0, 0.0), // Focal Point
  QVector3D(0.0, 1.0, 0.0)); // Up vector
QMatrix4x4 proj;
// Window size is fixed at …
Run Code Online (Sandbox Code Playgroud)

c++ opengl qt

2
推荐指数
1
解决办法
2811
查看次数