undefined reference bei libyaml

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • undefined reference bei libyaml

    Hallo Leute.
    Ich bin jetzt schon seit ein paar Wochen C am lernen. Nun wollte ich gerne YAML in C benutzen. Dazu hab ich mir eine passende C-Bibliothek namens libyaml gesucht.
    Dort gibt es im SVN-Repository auch Beispieldateien. Libyaml selbst habe ich über meine Paketverwaltung (gentoo mit emerge) in der Version 0.1.2 installiert.
    Mit den Beispieldateien, welche übrigens mit unzähligen Fehlern abbrach, habe ich mir versucht eine eigene Datei zu programmieren.
    Jedoch kommt immer der Fehler undefined reference to `yaml_emitter_initialize'. Die yaml.h, welche in /usr/include/ liegt, wird auch korrekt eingebunden.
    Hier mal mein bisheriger Code:

    Quellcode

    1. /*
    2. * yaml.c
    3. *
    4. * Created on: 06.12.2010
    5. * Author: markus
    6. *
    7. * Datei zum Testen und ausprobieren der libyaml und (l)stat
    8. */
    9. #include <yaml.h>
    10. #include <stdio.h>
    11. #include <stdlib.h>
    12. int main(int argc, char **argv) {
    13. yaml_parser_t parser;
    14. yaml_emitter_t emitter;
    15. yaml_event_t input_event;
    16. yaml_event_t output_event;
    17. memset(&parser, 0, sizeof(parser));
    18. memset(&emitter, 0, sizeof(emitter));
    19. memset(&input_event, 0, sizeof(input_event));
    20. memset(&output_event, 0, sizeof(output_event));
    21. //FILE *file = fopen("yaml.db", "wb");
    22. yaml_emitter_initialize(&emitter);
    23. //yaml_emitter_set_output_file(&parser, file);
    24. printf("Hallo\n");
    25. return EXIT_SUCCESS;
    26. }
    Alles anzeigen

    Ich habe dann nach etwas googlen herausgefunden, dass man wohl noch eine bereits kompilierte Datei einbinden muss.
    Dazu habe ich in /usr/lib64/ mit ls -l | grep libyaml folgendes gefunden:

    Quellcode

    1. lrwxrwxrwx 1 root root 18 6. Dez 19:59 libyaml-0.so.1 -> libyaml-0.so.1.1.0
    2. -rwxr-xr-x 1 root root 124944 6. Dez 19:59 libyaml-0.so.1.1.0
    3. -rw-r--r-- 1 root root 170032 6. Dez 19:59 libyaml.a
    4. -rw-r--r-- 1 root root 943 6. Dez 19:59 libyaml.la
    5. lrwxrwxrwx 1 root root 18 6. Dez 19:59 libyaml.so -> libyaml-0.so.1.1.0

    Anschließend habe ich es mit gcc -L/usr/lib64 -I yaml -o yaml yaml.c versucht die Bibliothek einzubinden. Leider ohne Erfolg, der Fehler blieb der gleiche.
    Dann habe ich es manuell mit dem Linker probiert:

    Quellcode

    1. gcc -c yaml.c
    2. ld yaml.o /usr/lib64/libyaml.a
    3. ld: warning: cannot find entry symbol _start; defaulting to 00000000004000f0
    4. yaml.o: In function `main':
    5. yaml.c:(.text+0x2d): undefined reference to `memset'
    6. yaml.c:(.text+0x46): undefined reference to `memset'
    7. yaml.c:(.text+0x5f): undefined reference to `memset'
    8. yaml.c:(.text+0x78): undefined reference to `memset'
    9. yaml.c:(.text+0x91): undefined reference to `puts'
    10. /usr/lib64/libyaml.a(api.o): In function `yaml_document_get_root_node':
    11. (.text+0x16e): undefined reference to `__assert_fail'
    12. /usr/lib64/libyaml.a(api.o): In function `yaml_document_get_node':
    13. (.text+0x1c4): undefined reference to `__assert_fail'
    14. /usr/lib64/libyaml.a(api.o): In function `yaml_emitter_set_break':
    15. (.text+0x1f1): undefined reference to `__assert_fail'
    16. /usr/lib64/libyaml.a(api.o): In function `yaml_emitter_set_unicode':
    17. (.text+0x225): undefined reference to `__assert_fail'
    18. /usr/lib64/libyaml.a(api.o): In function `yaml_emitter_set_width':
    19. (.text+0x25c): undefined reference to `__assert_fail'
    20. /usr/lib64/libyaml.a(api.o):(.text+0x297): more undefined references to `__assert_fail' follow
    21. /usr/lib64/libyaml.a(api.o): In function `yaml_string_write_handler':
    22. (.text+0x786): undefined reference to `memcpy'
    23. /usr/lib64/libyaml.a(api.o): In function `yaml_string_write_handler':
    24. (.text+0x7a8): undefined reference to `memcpy'
    25. /usr/lib64/libyaml.a(api.o): In function `yaml_string_read_handler':
    26. (.text+0x7e8): undefined reference to `memcpy'
    27. /usr/lib64/libyaml.a(api.o): In function `yaml_file_write_handler':
    28. (.text+0x823): undefined reference to `fwrite'
    29. /usr/lib64/libyaml.a(api.o): In function `yaml_file_read_handler':
    30. (.text+0x84b): undefined reference to `fread'
    31. /usr/lib64/libyaml.a(api.o): In function `yaml_file_read_handler':
    32. (.text+0x858): undefined reference to `ferror'
    33. /usr/lib64/libyaml.a(api.o): In function `yaml_alias_event_initialize':
    34. (.text+0x8fe): undefined reference to `__assert_fail'
    35. /usr/lib64/libyaml.a(api.o): In function `yaml_alias_event_initialize':
    36. (.text+0x917): undefined reference to `__assert_fail'
    37. /usr/lib64/libyaml.a(api.o): In function `yaml_document_delete':
    38. (.text+0x9e7): undefined reference to `__assert_fail'
    39. /usr/lib64/libyaml.a(api.o): In function `yaml_document_delete':
    40. (.text+0xaa4): undefined reference to `__assert_fail'
    41. /usr/lib64/libyaml.a(api.o): In function `yaml_event_delete':
    42. (.text+0xb80): undefined reference to `__assert_fail'
    43. /usr/lib64/libyaml.a(api.o):(.text+0xc74): more undefined references to `__assert_fail' follow
    44. /usr/lib64/libyaml.a(api.o): In function `yaml_queue_extend':
    45. (.text+0x11f4): undefined reference to `memmove'
    46. /usr/lib64/libyaml.a(api.o): In function `yaml_document_append_mapping_pair':
    47. (.text+0x13ae): undefined reference to `__assert_fail'
    48. /usr/lib64/libyaml.a(api.o): In function `yaml_document_append_mapping_pair':
    49. (.text+0x13c7): undefined reference to `__assert_fail'
    50. /usr/lib64/libyaml.a(api.o): In function `yaml_document_append_mapping_pair':
    51. (.text+0x13e0): undefined reference to `__assert_fail'
    52. /usr/lib64/libyaml.a(api.o): In function `yaml_document_append_mapping_pair':
    53. (.text+0x13f9): undefined reference to `__assert_fail'
    54. /usr/lib64/libyaml.a(api.o): In function `yaml_document_append_mapping_pair':
    55. (.text+0x1412): undefined reference to `__assert_fail'
    56. /usr/lib64/libyaml.a(api.o):(.text+0x14d3): more undefined references to `__assert_fail' follow
    57. /usr/lib64/libyaml.a(api.o): In function `yaml_string_extend':
    58. (.text+0x155c): undefined reference to `memset'
    59. /usr/lib64/libyaml.a(api.o): In function `yaml_string_join':
    60. (.text+0x15f7): undefined reference to `memcpy'
    61. /usr/lib64/libyaml.a(api.o): In function `yaml_document_initialize':
    62. (.text+0x18db): undefined reference to `__assert_fail'
    63. /usr/lib64/libyaml.a(api.o): In function `yaml_document_initialize':
    64. (.text+0x198f): undefined reference to `__assert_fail'
    65. /usr/lib64/libyaml.a(api.o): In function `yaml_document_initialize':
    66. (.text+0x19a8): undefined reference to `__assert_fail'
    67. /usr/lib64/libyaml.a(api.o): In function `yaml_document_initialize':
    68. (.text+0x19c1): undefined reference to `__assert_fail'
    69. /usr/lib64/libyaml.a(api.o): In function `yaml_scalar_event_initialize':
    70. (.text+0x1add): undefined reference to `memcpy'
    71. /usr/lib64/libyaml.a(api.o): In function `yaml_scalar_event_initialize':
    72. (.text+0x1b5f): undefined reference to `__assert_fail'
    73. /usr/lib64/libyaml.a(api.o): In function `yaml_scalar_event_initialize':
    74. (.text+0x1b78): undefined reference to `__assert_fail'
    75. /usr/lib64/libyaml.a(api.o): In function `yaml_document_start_event_initialize':
    76. (.text+0x1e4b): undefined reference to `__assert_fail'
    77. /usr/lib64/libyaml.a(api.o): In function `yaml_document_start_event_initialize':
    78. (.text+0x1e64): undefined reference to `__assert_fail'
    79. /usr/lib64/libyaml.a(api.o): In function `yaml_document_start_event_initialize':
    80. (.text+0x1e7d): undefined reference to `__assert_fail'
    81. /usr/lib64/libyaml.a(api.o):(.text+0x1e96): more undefined references to `__assert_fail' follow
    82. /usr/lib64/libyaml.a(api.o): In function `yaml_document_add_scalar':
    83. (.text+0x286d): undefined reference to `memcpy'
    84. /usr/lib64/libyaml.a(api.o): In function `yaml_document_add_scalar':
    85. (.text+0x29ad): undefined reference to `__assert_fail'
    86. /usr/lib64/libyaml.a(api.o): In function `yaml_document_add_scalar':
    87. (.text+0x29c6): undefined reference to `__assert_fail'
    88. /usr/lib64/libyaml.a(api.o): In function `yaml_strdup':
    89. (.text+0x871): undefined reference to `__strdup'
    90. /usr/lib64/libyaml.a(api.o): In function `yaml_free':
    91. (.text+0x921): undefined reference to `free'
    92. /usr/lib64/libyaml.a(api.o): In function `yaml_realloc':
    93. (.text+0x119c): undefined reference to `realloc'
    94. /usr/lib64/libyaml.a(api.o): In function `yaml_realloc':
    95. (.text+0x11b0): undefined reference to `malloc'
    96. /usr/lib64/libyaml.a(api.o): In function `yaml_malloc':
    97. (.text+0x1620): undefined reference to `malloc'
    98. ###########################################
    99. ld yaml.o /usr/lib64/libyaml.so
    100. ld: warning: cannot find entry symbol _start; defaulting to 0000000000400430
    Alles anzeigen

    Mittlerweile bin ich mit meinem Latein am Ende. Vielleicht wisst ihr ja, was ich vergessen oder falsch gemacht habe.
    Open Source --> Programmieren aus Leidenschaft :!:

    Ich stehe weder für privaten Support per PM noch über einen IM zur Verfügung. Danke.

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Deadman44 ()