命名空间限定符在编译中丢失

时间:2017-02-25 06:29:52

标签: c++ arm

我正在处理一个令人讨厌的编译/链接器错误,涉及为Game Boy Advance编译的C ++自制程序。虽然我的库libsaturn正在使用正确的C ++符号进行编译,但编译器似乎丢弃了库头文件中给出的命名空间限定符,只是放置了未定义的符号,就好像它们有C链接一样。我使用nm检查了目标代码文件,并确认是这种情况。

This是我正在尝试构建的程序的完整存储库,尽管我在下面提供了一些代码段。编译存储库需要devkitARM安装和Node.js;我遗憾地确保Linux上的工作正常。

我最初使用devkitARM r46遇到了这个问题,但遗憾的是将事情重新拨回r45并没有缓解这个问题。我的代码已经被我的几个同行梳理过了,他们发现我的配置没有任何异常。

这是我正在处理的代码。考虑到我很少知道问题的根源在哪里,但是无论如何......我担心它不会那么有用。

src/mainloop.cc

bool saturn::mainloop( )
{
    return false;
}

include/saturn/mainloop.hh

namespace saturn
{
bool mainloop( );
}

test/src/main.cc

int main( )
{
    while(!saturn::mainloop( ))
    {
        // Do something here
    }

    return 0;
}
alex@henen-nesw saturn $ arm-none-eabi-nm -pC /tmp/saturn-buildtool/code/test+src+main.cc.o
00000000 T main
        U init
        U halt
        U mainloop
alex@henen-nesw saturn $ arm-none-eabi-nm -pC libsaturn.a

src+bios.cc.o:
00000000 T bios::halt()
        U _sat__bios_halt
00000014 T bios::softReset()
        U _sat__bios_soft_reset
00000028 T bios::waitInterrupt(unsigned long, unsigned long)
        U _sat__bios_intr_wait
0000004c T bios::waitVblank()
        U _sat__bios_vblank_intr_wait

src+bootsector.s.o:
00000000 T __start
000000c0 T _sat__rom_start
000000ec T _sat__irq_handler
        U main

src+error.cc.o:
00000000 r kDispcntBgMode0
00000002 r kDispcntBgMode1
00000004 r kDispcntBgMode2
00000006 r kDispcntBgMode3
00000008 r kDispcntBgMode4
0000000a r kDispcntBgMode5
0000000c r kDispcntCgbMode
0000000e r kDispcntFrameSel
00000010 r kDispcntHblankIntv
00000012 r kDispcntObjVramDim
00000014 r kDispcntForceBlank
00000016 r kDispcntShowBg0
00000018 r kDispcntShowBg1
0000001a r kDispcntShowBg2
0000001c r kDispcntShowBg3
0000001e r kDispcntShowObj
00000020 r kDispcntShowWin0
00000022 r kDispcntShowWin1
00000024 r kDispcntShowObjWin
00000028 r ioDispcnt
0000002c r ioGreenswap
00000030 r kDispstatVblank
00000032 r kDispstatHblank
00000034 r kDispstatVcounter
00000036 r kDispstatVblankIrq
00000038 r kDispstatHblankIrq
0000003a r kDispstatVcounterIrq
0000003c r ioDispstat
00000040 r ioVcount
00000044 r kBgcntMosaic
00000046 r kBgcntPalMode4
00000048 r kBgcntPalMode8
0000004a r kBgcntOverflow
0000004c r ioBg0cnt
00000050 r ioBg1cnt
00000054 r ioBg2cnt
00000058 r ioBg3cnt
0000005c r ioBg0hofs
00000060 r ioBg0vofs
00000064 r ioBg1hofs
00000068 r ioBg1vofs
0000006c r ioBg2hofs
00000070 r ioBg2vofs
00000074 r ioBg3hofs
00000078 r ioBg3vofs
0000007c r ioBg2pa
00000080 r ioBg2pb
00000084 r ioBg2pc
00000088 r ioBg2pd
0000008c r ioBg2xL
00000090 r ioBg2xH
00000094 r ioBg2yL
00000098 r ioBg2yH
0000009c r ioBg3pa
000000a0 r ioBg3pb
000000a4 r ioBg3pc
000000a8 r ioBg3pd
000000ac r ioBg3xL
000000b0 r ioBg3xH
000000b4 r ioBg3yL
000000b8 r ioBg3yH
000000bc r ioWin0H
000000c0 r ioWin1H
000000c4 r ioWin0V
000000c8 r ioWin1V
000000cc r ioWinIn
000000d0 r ioWinOut
000000d4 r ioMosaic
000000d8 r ioBldcnt
000000dc r ioBldalpha
000000e0 r ioBldy
000000e4 r segBios
000000e8 r segEwram
000000ec r segIwram
000000f0 r segIo
000000f4 r segPal
00000000 b segPalBg
000000f8 r segPalObj
000000fc r segVram
00000004 b segVramBg
00000100 r segVramObj
00000104 r segOam
00000108 r segRom
0000010c r segSram
00000110 r ioDma0sad
00000114 r ioDma0dad
00000118 r ioDma0cntL
0000011c r ioDma0cntH
00000120 r ioDma1sad
00000124 r ioDma1dad
00000128 r ioDma1cntL
0000012c r ioDma1cntH
00000130 r ioDma2sad
00000134 r ioDma2dad
00000138 r ioDma2cntL
0000013c r ioDma2cntH
00000140 r ioDma3sad
00000144 r ioDma3dad
00000148 r ioDma3cntL
0000014c r ioDma3cntH
000000a0 t __static_initialization_and_destruction_0(int, int)
000000e4 t _GLOBAL__sub_I_error.cc
00000000 T saturn::error(saturn::Error)

src+init.cc.o:
00000000 T saturn::init()
        U saturn::error(saturn::Error)

src+lowbios.s.o:
00000000 T _sat__bios_soft_reset
00000004 T _sat__bios_register_ram_reset
00000008 T _sat__bios_halt
0000000c T _sat__bios_stop
00000010 T _sat__bios_intr_wait
00000014 T _sat__bios_vblank_intr_wait
00000018 T _sat__bios_div
0000001c T _sat__bios_div_arm
00000020 T _sat__bios_sqrt
00000024 T _sat__bios_arc_tan
00000028 T _sat__bios_arc_tan2
0000002c T _sat__bios_cpu_set
00000030 T _sat__bios_cpu_fast_set
00000034 T _sat__bios_bg_affine_set
00000038 T _sat__bios_obj_affine_set
0000003c T _sat__bios_bit_unpack
00000040 T _sat__bios_lzss_decomp_wram
00000044 T _sat__bios_lzss_decomp_vram
00000048 T _sat__bios_huff_decomp
0000004c T _sat__bios_rl_decomp_wram
00000050 T _sat__bios_rl_decomp_vram
00000054 T _sat__bios_diff_8bit_unfilter_wram
00000058 T _sat__bios_diff_8bit_unfilter_vram
0000005c T _sat__bios_diff_16bit_unfilter
00000060 T _sat__bios_sound_bias
00000064 T _sat__bios_midi_key_to_freq
00000068 T _sat__bios_multi_boot

src+mainloop.cc.o:
00000000 T saturn::mainloop()

src+math.cc.o:
00000000 T saturn::divide(long, long)
        U _sat__bios_div
00000030 T saturn::sqroot(unsigned long)
        U _sat__bios_sqrt
00000050 T saturn::modulus(long, long)

src+memory.cc.o:

谢谢!

1 个答案:

答案 0 :(得分:1)

这是一个简化的构建脚本,可以正确地链接测试程序:https://gist.github.com/nnevatie/9fe11e3933ed3f51e5344639c6881bd5