Dwarf error could not find abbrev number 84

With the standard Ubuntu 19.04 arm-gcc (7.3.1) there's no error. So I'd say it's either a regression in gcc 9 or something is wrong with the way you build the C library. extern "C&...

Your code produces multiple warnings.

main.cpp:2:5: warning: declaration of 'int _exit()' conflicts with built-in declaration 'void _exit(int)' [-Wbuiltin-declaration-mismatch]
    2 | int _exit(){}
      |     ^~~~~
main.cpp: In function 'int _exit()':
main.cpp:2:13: warning: no return statement in function returning non-void [-Wreturn-type]
    2 | int _exit(){}
      |             ^
main.cpp: In member function 'int HardwareSerial3::available()':
main.cpp:5:19: warning: no return statement in function returning non-void [-Wreturn-type]
    5 | int available() { }
      |                   ^

After fixing all of them:

extern "C"
void _exit(int){ while(1); }
int main() {}
class HardwareSerial3 {
void available() {}
};
void yield() {}
$ arm-none-eabi-g++ -o main.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -flto -g -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m4 -nostdlib -O2 main.cpp
$ arm-none-eabi-g++ -o firmware.elf -g -Wl,--gc-sections,--relax -mthumb -mcpu=cortex-m4 -O2 --specs=nano.specs -Wl,--start-group main.cpp.o -lm -lstdc++ -Wl,--end-group
$ arm-none-eabi-nm -ClS --radix=d --size-sort firmware.elf
00099761 00000001 B __lock___arc4random_mutex	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/lock.c:103
00099760 00000001 B __lock___atexit_recursive_mutex	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/lock.c:97
00099765 00000001 B __lock___at_quick_exit_mutex	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/lock.c:98
00099766 00000001 B __lock___dd_hash_mutex	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/lock.c:102
00099762 00000001 B __lock___env_recursive_mutex	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/lock.c:100
00099764 00000001 B __lock___malloc_recursive_mutex	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/lock.c:99
00099768 00000001 B __lock___sfp_recursive_mutex	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/lock.c:96
00099763 00000001 B __lock___sinit_recursive_mutex	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/lock.c:95
00099767 00000001 B __lock___tz_mutex	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/lock.c:101
00033068 00000002 T _exit	/tmp/main.cpp:2
00033596 00000002 T __retarget_lock_acquire_recursive
00033598 00000002 T __retarget_lock_release
00033600 00000002 T __retarget_lock_release_recursive
00099272 00000004 D __atexit_recursive_mutex	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/stdlib/__call_atexit.c:17
00099444 00000004 B _global_atexit
00033616 00000004 R _global_impure_ptr
00032820 00000004 T main	/tmp/main.cpp:3
00033072 00000012 T atexit	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/include/stdlib.h:76
00033196 00000016 T memset	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/include/string.h:33
00032780 00000040 T exit	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/include/stdlib.h:93
00033084 00000040 T __libc_fini_array	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/fini.c:26
00033124 00000072 T __libc_init_array	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/misc/init.c:30
00099176 00000096 d impure_data	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/reent/impure.c:23
00099304 00000140 b _global_atexit0	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/stdlib/__atexit.c:57
00033408 00000188 T __call_exitprocs	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/stdlib/__call_atexit.c:70
00033212 00000196 T __register_exitproc	/home/freddie/bleeding-edge-toolchain/sources/newlib-3.1.0/newlib/libc/stdlib/__atexit.c:68
00099448 00000312 B __sf

Even if there is a regressions, the error you see is not fatal (echo $? prints 0) and does not actually cause any problem (as the error message is printed to stderr, not stdout). Earlier versions of bleeding-edge-toolchain (gcc 6, gcc 7, gcc 8) also don’t print this error message, therefore I think the problem is not related to the way the toolchain is built, but most likely to something within binutils.

Edit: Sorry for closing, wrong button.

I have a TCP Client program (TCPClient.cpp) using winsock library. An *.exe is generated successfully if I use command line with the following call:

g++ TCPClient.cpp -o TCPClient.exe -lws2_32

When I try to compile and link the same script within Eclipse/C++ using MinGW I seem to get the *.o file generated but I get an error when generating the *.exe.
Thus, the error is generated if Ecplise/C++ does the following (linker call):

g++ -o TCPClient.exe TCPClient.o -lws2_32 

I get multiple errors:

enter C:MinGWbinld.exe: Dwarf Error: Could not find abbrev number 84.
./src/TCPClient.o:cygming-crtbegin.c:(.text+0x2a0): multiple definition of
_mingw32_init_mainargs
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x2a0): first defined here
C:MinGWbinld.exe: Dwarf Error: Could not find abbrev number 84.
./src/TCPClient.o:cygming-crtbegin.c:(.text+0x2e0): multiple definition of
mainCRTStartup' c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x2e0): first defined here C:MinGWbinld.exe: Dwarf Error: Could not find abbrev number 84. ./src/TCPClient.o:cygming-crtbegin.c:(.text+0x300): multiple definition of WinMainCRTStartup’
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x300): first defined here
C:MinGWbinld.exe: Dwarf Error: Could not find abbrev number 84.
./src/TCPClient.o:cygming-crtbegin.c:(.text+0x320): multiple definition of atexit' c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x320): first defined here C:MinGWbinld.exe: Dwarf Error: Could not find abbrev number 84. ./src/TCPClient.o:cygming-crtbegin.c:(.text+0x330): multiple definition of _onexit’
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x330): first defined here
C:MinGWbinld.exe: Dwarf Error: Could not find abbrev number 84.
./src/TCPClient.o:cygming-crtbegin.c:(.text+0x340): multiple definition of
`__gcc_register_frame’
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0x0): first
defined here
C:MinGWbinld.exe: Dwarf Error: Could not find abbrev number 84.here

The following is interesting:
I get the same errors if I use the cmd-line and first generate a .o file and then try to generate a *.exe. Both of the following calls in cmd-line result in the error from above:

g++ TCPClient.o -o TCPClient.exe -lws2_32

g++ TCPClient.o -o TCPClient.exe 

This means: If in cmd-line I only specify that I want to generate (a *.exe from my *.cpp) everything works fine. But — as a user — doing those two steps separately does not work.

Cmd-Line g++ call seems to «know» what to do here. As a user I never see the *.o file when directly generating a *.exe. But I think it must be generated anyway? Am I wrong? Why does cmd-line without further specification know how to deal with the .o file? … Is it possible to find out from any source what a call to «g++» does when called via command line? Of course I want the same settings integrated in eclipse/c++.

Thread overview
[Issue 3214] New: Incorrect DWARF line number debugging information on Linux

Jul 29, 2009

nfxjfg@gmail.com

Jul 30, 2009

nfxjfg@gmail.com

Sep 08, 2009

Robert Clipsham

Nov 22, 2009

nfxjfg@gmail.com

Nov 23, 2009

nfxjfg@gmail.com

Apr 01, 2010

nfxjfg@gmail.com

Jan 07, 2011

nfxjfg@gmail.com

Jan 07, 2011

Brad Roberts

Apr 04, 2011

Walter Bright

July 29, 2009

[Issue 3214] New: Incorrect DWARF line number debugging information on Linux

Gravatar of nfxjfg@gmail.com Posted by nfxjfg@gmail.com PermalinkReply
Gravatar of nfxjfg@gmail.com

PermalinkReply

http://d.puremagic.com/issues/show_bug.cgi?id=3214

           Summary: Incorrect DWARF line number debugging information on
                    Linux
           Product: D
           Version: 1.046
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: nfxjfg@gmail.com


Here's an example that shows that dmd obviously/probably generates incorrect DWARF line number debugging information under Linux. The example consists of several modules, and I don't know if it's further reducible, or where the problem actually is. (I'm happy that's it's reproducible at all.)

a.d >>>
module a;

import b;

void main(char[][] args) {
    throw new Exception("huh");
}
<<<

b.d >>>
module b;

import c;

void foo1() {
}
<<<

c.d >>>
module c;

class Foo2 : Exception {
    this() {
        super("huh");
    }
}
<<<

Compile exactly like this:
  dmd -c a.d b.d c.d -od. -g
  dmd  a.o b.o c.o  -ofa -g

Now look what is wrong and check if the symbol "_D1c4Foo25_ctorMFZC1c4Foo2" is correct:

1. Get address:
  nm a|grep _D1c4Foo25_ctorMFZC1c4Foo2 |cut -f2 -d: | cut -f1 -d' '
(outputs something like "08049b64")
2. Resolve the address:
  addr2line -e a 0x08049b64

This outputs "/tmp/test/xx/b.d:5", although the symbol is in c.d. Somehow, the address is incorrectly resolved, which suggests that the compiler might generate incorrect debugging information.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

July 30, 2009

[Issue 3214] Incorrect DWARF line number debugging information on Linux

Gravatar of nfxjfg@gmail.com Posted by nfxjfg@gmail.com
in reply to nfxjfg@gmail.com
PermalinkReply

nfxjfg@gmail.com

Gravatar of nfxjfg@gmail.com


Posted in reply to nfxjfg@gmail.com

PermalinkReply

http://d.puremagic.com/issues/show_bug.cgi?id=3214





--- Comment #1 from nfxjfg@gmail.com  2009-07-29 21:19:56 PDT ---
Created an attachment (id=435)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=435)
dmd patch to fix the problem (against dmd 1.046)

I think I found out why it doesn't work: when compiling several files at once, the object writer's state isn't reset correctly. Now I don't know how the hell the backend works; I just noticed that the DWARF writer still tried to write line numbers from the previous file (also notice what's added by objlinnum()). In this case, c.o contained some line number information from b.o, which is why addr2line resolved the address mentioned to b.d.

I'm posting a trivial 3 line patch that seems to solve the problem. It simply makes obj_init() forget about the SegData from the previous object file. I don't know if it's correct or complete, but with my test cases (the one posted above and a larger, non-trivial heap of code) it seemed to work very well. The patch causes a little memory leak, but that'd trivial to fix (maybe not setting seg_max to 0 does it).

There's just one more problem. When resolving some invalid address with addr2line, I get this output:

BFD: Dwarf Error: mangled line number section (bad file number).
BFD: Dwarf Error: mangled line number section (bad file number).
BFD: Dwarf Error: Could not find abbrev number 1014.
BFD: Dwarf Error: Could not find abbrev number 119.
BFD: Dwarf Error: Could not find abbrev number 651.
BFD: Dwarf Error: Could not find abbrev number 53.
BFD: Dwarf Error: Could not find abbrev number 84.
BFD: Dwarf Error: Could not find abbrev number 657.
BFD: Dwarf Error: Could not find abbrev number 1230.

I have no idea what's up with that and I can't reproduce it with a simpler testcase.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

September 08, 2009

[Issue 3214] Incorrect DWARF line number debugging information on Linux

Gravatar of Robert Clipsham Posted by Robert Clipsham
in reply to nfxjfg@gmail.com
PermalinkReply

Robert Clipsham

Gravatar of Robert Clipsham


Posted in reply to nfxjfg@gmail.com

PermalinkReply

http://d.puremagic.com/issues/show_bug.cgi?id=3214


Robert Clipsham <robert@octarineparrot.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |robert@octarineparrot.com


--- Comment #2 from Robert Clipsham <robert@octarineparrot.com> 2009-09-08 05:49:22 PDT ---
Don't forget to add the patch keyword along with the patch so it doesn't get missed :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

November 22, 2009

[Issue 3214] Incorrect DWARF line number debugging information on Linux

Gravatar of nfxjfg@gmail.com Posted by nfxjfg@gmail.com
in reply to nfxjfg@gmail.com
PermalinkReply

nfxjfg@gmail.com

Gravatar of nfxjfg@gmail.com


Posted in reply to nfxjfg@gmail.com

PermalinkReply

http://d.puremagic.com/issues/show_bug.cgi?id=3214


nfxjfg@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |3540


--- Comment #3 from nfxjfg@gmail.com 2009-11-21 18:28:15 PST ---
Also see 3540.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

November 23, 2009

[Issue 3214] Incorrect DWARF line number debugging information on Linux

Gravatar of nfxjfg@gmail.com Posted by nfxjfg@gmail.com
in reply to nfxjfg@gmail.com
PermalinkReply

nfxjfg@gmail.com

Gravatar of nfxjfg@gmail.com


Posted in reply to nfxjfg@gmail.com

PermalinkReply

http://d.puremagic.com/issues/show_bug.cgi?id=3214



--- Comment #4 from nfxjfg@gmail.com 2009-11-22 21:40:49 PST ---
Problem still persists in dmd 1.051 and the dmd svn version (as of revision
267).

I assume there is some other problem, that doesn't make fixing the bug as simple as it seems?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

April 01, 2010

[Issue 3214] Incorrect DWARF line number debugging information on Linux

Gravatar of nfxjfg@gmail.com Posted by nfxjfg@gmail.com
in reply to nfxjfg@gmail.com
PermalinkReply

nfxjfg@gmail.com

Gravatar of nfxjfg@gmail.com


Posted in reply to nfxjfg@gmail.com

PermalinkReply

http://d.puremagic.com/issues/show_bug.cgi?id=3214



--- Comment #5 from nfxjfg@gmail.com 2010-04-01 05:58:19 PDT ---
It's strange...
With my patch, my executable has a size of 16 MB, with a .debug_line section
size of ca. 500 KB.
Without my patch, it's 32 MB, of which .debug_line takes up 16 MB.

PS:

With the fix for bug 3987, the addr2line error messages go away (when compiling
with -gc).
Which means my patch doesn't cause additional problems at least in this aspect.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

January 07, 2011

[Issue 3214] Incorrect DWARF line number debugging information on Linux

Gravatar of nfxjfg@gmail.com Posted by nfxjfg@gmail.com
in reply to nfxjfg@gmail.com
PermalinkReply

nfxjfg@gmail.com

Gravatar of nfxjfg@gmail.com


Posted in reply to nfxjfg@gmail.com

PermalinkReply

http://d.puremagic.com/issues/show_bug.cgi?id=3214


nfxjfg@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

January 07, 2011

[Issue 3214] Incorrect DWARF line number debugging information on Linux

Gravatar of Brad Roberts Posted by Brad Roberts
in reply to nfxjfg@gmail.com
PermalinkReply

Brad Roberts

Gravatar of Brad Roberts


Posted in reply to nfxjfg@gmail.com

PermalinkReply

http://d.puremagic.com/issues/show_bug.cgi?id=3214


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |braddr@puremagic.com
         Resolution|WONTFIX                     |


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

April 04, 2011

[Issue 3214] Incorrect DWARF line number debugging information on Linux

Gravatar of Walter Bright Posted by Walter Bright
in reply to nfxjfg@gmail.com
PermalinkReply

Walter Bright

Gravatar of Walter Bright


Posted in reply to nfxjfg@gmail.com

PermalinkReply

http://d.puremagic.com/issues/show_bug.cgi?id=3214


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2011-04-04 12:36:33 PDT ---
https://github.com/D-Programming-Language/dmd/commit/01aab6459cfba2eb85feb1481c01c17b8a3badfe

https://github.com/D-Programming-Language/dmd/commit/5f1a6afb1363fe950d2392748fc35f5914c6c6f5

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

У меня проблемы с использованием Boost в автономном приложении .exe.

Я использую IDE CodeBlocks с компилятором minGW и Boost версии 1.67. В параметрах сборки-> каталоги поиска-> компилятор я связал $(#boost) и в Linker $(#boost.lib).

Вот код:

#include <iostream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>

int main()
{
    using boost::property_tree::ptree;
    ptree tree;
    try
    {
        read_ini("C:\Users\M0097932\Desktop\firstTest\torque_trac2_L0.eds", tree);
    std::cout << "test" << std::endl;
    }
    catch(...)
    {
        std::cout << "error" << std::endl;
    }
    for (auto& section : tree) //iterate over tree and print all entries
    {
        std::cout << '[' << section.first << "]n";
        for (auto& key : section.second)
            std::cout << key.first << " = " << key.second.get_value<std::string>() << "n";
    }

    std::cout << std::endl << "Done" << std::endl;
}

Приложение работает нормально, если я запускаю его через IDE (оно печатает все и выходит со статусом 0). Когда я запускаю файл .exe из binDebug, программа падает, и я не получаю никаких исключений («[файл] перестал работать»). Он падает при вызове функции read_ini() (я знаю это, потому что не вижу «тест» в cmd).

Почему приложение вылетает и как это исправить?

Обновлено: Некоторая дополнительная информация по запросу.

INI-файл: C:UsersM0097932DesktopfirstTesttorque_trac2_L0.eds

[1018]
ParameterName=Identity object
ObjectType=0x9
SubNumber=3

[1018sub0]
ParameterName=Number of entries
ObjectType=0x7
DataType=0x0005
AccessType=ro
DefaultValue=3
PDOMapping=0
LowLimit=1
HighLimit=4

[1018sub1]
ParameterName=Vender ID
ObjectType=0x7
DataType=0x0007
AccessType=ro
DefaultValue=0x0400005A
PDOMapping=0

Если я запускаю программу .exe через cmd («DataGetter.exe»), при сбое программы ошибка не появляется.

Если я поставлю «g++ DataGetter.exe» в cmd, я получу множество ошибок (но я не уверен, что должен запускать файл .exe таким образом)

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf
Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x2a0): multiple definition of `_mingw32_init_mainargs'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x2a0): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x2e0): multiple definition of `mainCRTStartup'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x2e0): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x300): multiple definition of `WinMainCRTStartup'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x300): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x320): multiple definition of `atexit'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x320): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x330): multiple definition of `_onexit'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x330): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x340): multiple definition of `__gcc_register_frame'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0x0): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x430): multiple definition of `__gcc_deregister_frame'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0xf0): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e54): multiple definition of `_imp___ZSt4cerr'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e54): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e8c): multiple definition of `_imp___ZTVSt9exception'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e8c): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e88): multiple definition of `_imp___ZTVN10__cxxabiv121__vmi_class_type_infoE'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e88): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.bss+0x4): multiple definition of `_argc'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.bss+0x4): first definedhere
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.bss+0x0): multiple definition of `_argv'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.bss+0x0): first definedhere
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e58): multiple definition of `_imp___ZSt4cout'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e58): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e7c): multiple definition of `_imp___ZTISt15basic_streambufIcSt11char_traitsIcEE'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e7c): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e80): multiple definition of `_imp___ZTVN10__cxxabiv117__class_type_infoE'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e80): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e84): multiple definition of `_imp___ZTVN10__cxxabiv120__si_class_type_infoE'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e84): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1c74): multiple definition of `_imp___ZNSt12placeholders2_1E'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1c74): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.eh_frame+0xb8): multiple definition of `__EH_FRAME_BEGIN__'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.eh_frame+0x0): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0x92): undefined reference to `_Jv_RegisterClasses'
collect2.exe: error: ld returned 1 exit status

У меня проблемы с моим школьным проектом. Я думаю, что это может быть ошибка при использовании указателей, но я не уверен, почему я получаю эту ошибку. Этот код неполон, но я пытаюсь проверить его по пути. У вас есть идея, почему я получаю эту ошибку и что это значит? Спасибо!

Ошибка от терминала Cygwin

-bash-3.2$ make clean
rm -rf *.o simulate
-bash-3.2$ make simulate
g++ -c -g Main.cpp
g++ -c -g Maze.cpp
g++ Main.o Maze.o -o simulate
/usr/bin/ld: Dwarf Error: found dwarf version '4', this reader only handles version 2 information.
Maze.o: In function `Maze::createMaze(char*)':
Maze.cpp:(.text+0x49): undefined reference to `Node::Node(char)'
collect2: error: ld returned 1 exit status
make: *** [simulate] Error 1

main.cpp

#include <iostream>
#include <fstream>
#include <string>
#include "Maze.h"using namespace std;

int main()
{
int array_size = 1024;
char * mazeArray = new char[array_size];
int position = 0;
string mazeName;
Maze Maze1;

cout << "Enter the name of the maze file: ";
getline(cin, mazeName);

ifstream fin(mazeName.c_str());
//File opened successfully
if(fin.is_open())
{
while(!fin.eof() && position < array_size)
{
fin.get(mazeArray[position]); //reading one character from file to mazeArray
position++;
}
mazeArray[position-1] = ''; //placing character mazeArray terminating character

for(int i = 0; mazeArray[i] != ''; i++){
if(isspace(mazeArray[i]))
mazeArray[i] = mazeArray[i+1];
}

cout << "Displaying mazeArray..." << endl << endl;
//this loop display all the charaters in mazeArray till 
for(int i = 0; mazeArray[i] != ''; i++)
{
cout << mazeArray[i];
}
cout << endl;

Maze1.createMaze(mazeArray);

}
else //file could not be opened
{
cout << "File could not be opened." << endl;
}

return 0;
}

Maze.h

#ifndef MAZE_H
#define MAZE_H
#include <string>
#include <sstream>
#include <vector>

#include "Node.h"using namespace std;

class Maze
{
public:
void createMaze(char*);
void availablePaths();
void displayPath();
void moveNorth();
void moveSouth();
void moveEast();
void moveWest();
int getroomCount();
char getpathHistory();
char getcurrentRoom();

private:
int roomCount;
char pathHistory[];
Node* currentRoom;
Node* nodeArray[12];
struct isPath;
vector<Node*> nodeVector;

};

#endif

Maze.cpp

#include <iostream>
#include <string>

#include "Maze.h"
using namespace std;

Node* Node1;

void Maze::createMaze(char *inFile){
int count = 0;

//Creates Nodes for Maze
for(int ii = 0; ii <= 12; ii++){
Node1 = new Node(inFile[count]);
nodeVector.push_back(Node1);
count = count + 5;

//If there is not another node break out of the for loop.
if(inFile[count] == ''){
break;
}
}

}

void Maze::availablePaths(){

}

void Maze::displayPath(){

}

void Maze::moveNorth(){

}

void Maze::moveSouth(){

}

void Maze::moveEast(){

}

void Maze::moveWest(){

}

int Maze::getroomCount(){

}

char Maze::getpathHistory(){

}

char Maze::getcurrentRoom(){

}

node.h

#ifndef NODE_H
#define NODE_H
#include <string>
#include <map>
#include <sstream>
using namespace std;

class Node
{
public:
Node(char);
void setNodeName(char);
void attachNewNode(Node, int);
Node *getAttachedNode(int);
private:
char name; // Title that is displayed above the menu.
Node *attachedNodes[4];
};

#endif

node.cpp

#include <iostream>
#include <string>
#include <vector>

#include "Node.h"using namespace std;

Node::Node(char name) : name(name) {

}

void Node::setNodeName(char tempName){
name = tempName;
}

void Node::attachNewNode(Node temp, int direction){
attachedNodes[direction] = temp;
}

Node Node::getAttachedNode(int direction){
return attachedNodes[direction];
}

Makefile

#!/bin/bash
#file:makefile
CC = g++
CFLAGS = -c -g

simulate: Main.o Maze.o
$(CC) Main.o Maze.o -o simulate

Main.o: Main.cpp Maze.h
$(CC) $(CFLAGS) Main.cpp

Maze.o: Maze.cpp Menu.h Node.h
$(CC) $(CFLAGS) Maze.cpp
Node.o: Node.cpp Node.h
$(CC) $(CFLAGS) Node.cpp

clean:
rm -rf *.o simulate

2

Решение

Проблема не в вашем коде, как таковая.

Одна из проблем заключается в том, что ваша команда линковки не работает, потому что вы не связываете все свои объектные файлы. Вам нужно ссылку Main.o, Maze.o а также Node.o создать исполняемый файл:

g++ Main.o Maze.o Node.o -o simulate

Другая проблема в том, что ваш компилятор новее, чем ваш компоновщик. Компилятор генерирует отладочную информацию, используя Dwarf версии 4, но ваш компоновщик (/usr/bin/ld) понимает только Dwarf версии 2.

/usr/bin/ld: Dwarf Error: found dwarf version '4', this reader only handles
version 2 information.

Вам необходимо обновить ваш компоновщик до более новой версии, совместимой с используемым вами компилятором.

Или как janneb предлагает в комментарий, ты можешь использовать -gdwarf-2 как в компиляции, так и в ссылочных строках. в makefile:

CFLAGS = -c -gdwarf-2

FILES.cpp = Main.cpp Maze.cpp Node.cpp
FILES.o   = $(FILES.cpp:.cpp=.o}

simulate: $(FILES.o)
$(CC) $(CFLAGS) $(FILES.o) -o $@

(В командной строке должно быть несколько частей makefile это не макро-вызовы; тогда вы можете изменить все более легко.)

Вам нужно будет удалить объектные файлы Dwarf-4 и перекомпилировать, чтобы избежать появления ошибки / предупреждения.

3

Другие решения

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Dwo1a как изменить ток защиты
  • Dwmcore dll ошибка
  • Dwm exe системная ошибка как исправить
  • Dwm exe ошибочный образ windows 7
  • Dwm exe windows 7 ошибка приложения

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии