English 中文(简体)
预先编造的主编和汇编OSX上的通用物体
原标题:Precompiled headers and compiling universal objects on OSX

我们正在利用海合会的有预谋的负责人开展我们的项目,并建设这样的领导:

gcc $(CFLAGS) precompiledcommonlib.h

现在,我把该项目建设在10.6号行动之上,并试图像现在这样利用所有建筑建筑的修饰特征:

gcc $(CFLAGS) -c -arch i386 -arch x86_64 commonlib.c  

然而,这似乎不利于有预谋的负责人:

gcc $(CFLAGS) -arch i386 -arch x86_64 precompiledcommonlib.h
Undefined symbols for architecture i386:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
Undefined symbols for architecture x86_64:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
lipo: can t open input file: /var/folders/z1/z1A0sPkqGDyPrZWo9ysVK++++TI/-Tmp-//cc3W2gwd.out (No such file or directory)

Edit: As Mark pointed out as per XCode the precompiled header has to be built separately for each architecture, so my question is rather if there is any way to have gcc use the right precompiled header when building universal objects.

我确实相信,我可以像锡德这样的完全分开建造每个建筑,但我会利用同时建造这些建筑的可能性,而不必与不同的建筑组合相邻。

最佳回答

我只谈同样的问题,接着谈到“蓝cas”提供的联系,因此,我认为我会提供我在这里发现的内容。

首先值得注意的是,如果你将自己的舱位代码从北纬度到北海,则由波段提供的舱位版本没有适当发现卷位延长。

mac:openstudio lefticus$ g++ test.hpp
ld: warning: ign或ing file test.hpp, file was built f或 unsupp或ted file f或mat which is not the architecture being linked (x86_64)
Undefined symbols f或 architecture x86_64:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found f或 architecture x86_64
collect2: ld returned 1 exit status

如另一项答复所述,最好具体说明-x的论点,以确保gcc知道你正在汇编哪类档案。

g++ -x c++-header test.hpp

这就产生了预期的<代码>测试.hpp.gch。

您可以具体说明指挥线上的任何结构,并适当建立这种结构。

g++ -x c++-header test.hpp -arch i386

g++ -x c++-header test.hpp -arch x86_64

If you provide m或e than one architecture, you get the err或 the poster mentioned.

mac:openstudio lefticus$ g++ -xc++-header test.hpp -arch i386 -arch x86_64
Undefined symbols f或 architecture i386:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found f或 architecture i386
collect2: ld returned 1 exit status
Undefined symbols f或 architecture x86_64:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found f或 architecture x86_64
collect2: ld returned 1 exit status
lipo: can t open input file: /var/folders/DM/DMTpbjzHHX08IEqGgEAORE+++TI/-Tmp-//ccDeWigf.out (No such file 或 direct或y)

关键是要汇编你所需要的结构,然后分别使用<代码>-Xarch_的论点,在汇编中填入适当的结构:

g++ -x c++-header -arch x86_64 x86_64/test.hpp
g++ -x c++-header -arch i386 i386/test.hpp

g++ -arch i386 -arch x86_64 test.cpp -Xarch_i386 -Ii386 -Xarch_x86_64 -Ix86_64
问题回答

你的问题不是结构问题。 两者都失败

问题是,你试图在没有主要职能的情况下建立一个可起诉的法庭。

由于档案名称是通用的。 我怀疑你是否希望建立一个图书馆,如果能够开始该项目,在锡古德建立一个图书馆模板。

这或许有助于你的工作。

valid output formats for -f are (`*  denotes default):
  * bin       flat-form binary files (e.g. DOS .COM, .SYS)
    ith       Intel hex
    srec      Motorola S-records
    aout      Linux a.out object files
    aoutb     NetBSD/FreeBSD a.out object files
    coff      COFF (i386) object files (e.g. DJGPP for DOS)
    elf32     ELF32 (i386) object files (e.g. Linux)
    elf64     ELF64 (x86_64) object files (e.g. Linux)
    elfx32    ELFX32 (x86_64) object files (e.g. Linux)
    as86      Linux as86 (bin86 version 0.3) object files
    obj       MS-DOS 16-bit/32-bit OMF object files
    win32     Microsoft Win32 (i386) object files
    win64     Microsoft Win64 (x86-64) object files
    rdf       Relocatable Dynamic Object File Format v2.0
    ieee      IEEE-695 (LADsoft variant) object file format
    macho32   NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (i386) object files
    macho64   NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (x86_64) object files
    dbg       Trace of all info passed to output stage
    elf       ELF (short name for ELF32)
    macho     MACHO (short name for MACHO32)
    win       WIN (short name for WIN32)




相关问题
gcc -fPIC seems to muck with optimization flags

Following along from this question: how-do-i-check-if-gcc-is-performing-tail-recursion-optimization, I noticed that using gcc with -fPIC seems to destroy this optimization. I am creating a shared ...

Generate assembler code from C file in linux

I would like to know how to generate assembler code from a C program using Unix. I tried the gcc: gcc -c file.c I also used firstly cpp and then try as but I m getting errors. I m trying to build an ...

Getting rid of pre-compiled headers

OK, I have old Metrowerks code for Mac and Windows where the previous developer used pre-compiled headers for every project that this code base builds. How does one get rid of Pre-compiled headers, ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

How to compile for Mac OS X 10.5

I d like to compile my application for version 10.5 and forward. Ever since I upgraded to Snow Leopard and installed the latest XCode, gcc defaults to 10.6. I ve tried -isysroot /Developer/SDKs/...

热门标签