2016-11-23 5 views
1

ich versuche zu bauen und installieren Sie den Apache Thrift Compiler und BibliothekenFehler: ‚strdup‘ wurde nicht in diesem Bereich erklärt

Wie in Anweisungen gezeigt laufen ./configure && make

Und ich bekomme diese Fehlermeldung:

thrift 0.9.3 

Building C++ Library ......... : no 
Building C (GLib) Library .... : no 
Building Java Library ........ : no 
Building C# Library .......... : no 
Building Python Library ...... : no 
Building Ruby Library ........ : no 
Building Haxe Library ........ : no 
Building Haskell Library ..... : no 
Building Perl Library ........ : no 
Building PHP Library ......... : no 
Building Erlang Library ...... : no 
Building Go Library .......... : no 
Building D Library ........... : no 
Building NodeJS Library ...... : no 
Building Lua Library ......... : no 

If something is missing that you think should be present, 
please skim the output of configure to find the missing 
component. Details are present in config.log. 
make all-recursive 
make[1]: Entering directory '/c/University/InternetOfThings/thrift-0.9.3' 
Making all in compiler/cpp 
make[2]: Entering directory '/c/University/InternetOfThings/thrift-0.9.3/compiler/cpp' 
/bin/sh ../../ylwrap src/thrifty.yy y.tab.c src/thrifty.cc y.tab.h `echo src/thrifty.cc | sed -e s/cc$/hh/ -e s/cpp$/hpp/ -e s/cxx$/hxx/ -e s/c++$/h++/ -e s/c$/h/` y.output src/thrifty.output -- bison -y -d 
updating src/thrifty.hh 
make all-am 
make[3]: Entering directory '/c/University/InternetOfThings/thrift-0.9.3/compiler/cpp' 
g++ -DHAVE_CONFIG_H -I. -I../.. -I../../lib/cpp/src/thrift -I./src -Wall -Wno-sign-compare -Wno-unused -g -O2 -std=c++11 -MT src/libparse_a-thrifty.o -MD -MP -MF src/.deps/libparse_a-thrifty.Tpo -c -o src/libparse_a-thrifty.o `test -f 'src/thrifty.cc' || echo './'`src/thrifty.cc 
src/thrifty.yy: In function 'int yyparse()': 
src/thrifty.yy:1311:30: error: 'strdup' was not declared in this scope 
Makefile:912: recipe for target 'src/libparse_a-thrifty.o' failed 
make[3]: *** [src/libparse_a-thrifty.o] Error 1 
make[3]: Leaving directory '/c/University/InternetOfThings/thrift-0.9.3/compiler/cpp' 
Makefile:588: recipe for target 'all' failed 
make[2]: *** [all] Error 2 
make[2]: Leaving directory '/c/University/InternetOfThings/thrift-0.9.3/compiler/cpp' 
Makefile:609: recipe for target 'all-recursive' failed 
make[1]: *** [all-recursive] Error 1 
make[1]: Leaving directory '/c/University/InternetOfThings/thrift-0.9.3' 
Makefile:530: recipe for target 'all' failed 
make: *** [all] Error 2 

Ich bearbeitet thrifty.yy und hinzugefügt #include <string.h> noch bekomme ich immer noch den gleichen Fehler, dass strdup fehlt.

src/thrifty.yy:1311:30: error: 'strdup' was not declared in this scope (gleiche Fehler wie zuvor einschließlich string.h)

Was soll ich hier fehlt?

Vielen Dank im Voraus!

+0

http://stackoverflow.com/questions/32944390/what-is -die-rationale-für-nicht-einschließlich-straddup-in-the-c-standard – Steephen

+0

Alles in config.log? – JensG

+0

Ist das Cygwin-Umgebung? Wäre schön zu wissen ... in diesem Fall sehen Sie [THRIFT-2800] (https://issues.apache.org/jira/browse/THRIFT-2800) – JensG

Antwort

2

strdup ist keine Standard-C-Funktion. Wenn ein Compiler so konfiguriert ist, dass er strikt C-konform ist, ist es nicht erlaubt, eigene benutzerdefinierte Nicht-Standardfunktionen in Standardbibliotheksheadern wie <string.h> auszugeben.

Sie können dies beheben, indem Sie den Compiler ändern, um nicht standardmäßigen C-Code zu kompilieren (z. B. in gcc, kompilieren Sie mit -std=gnu11 statt -std=c11). Oder alternativ, bleib bei reinem Standard C.


... oder implementieren nur strdup selbst, es ist einfach:

#include <string.h> 
#include <stdlib.h> 

char* strdup (const char* s) 
{ 
    size_t slen = strlen(s); 
    char* result = malloc(slen + 1); 
    if(result == NULL) 
    { 
    return NULL; 
    } 

    memcpy(result, s, slen+1); 
    return result; 
} 
+0

Das Hinzufügen der Implementierung von 'strdup' zu' thrifty.yy' ergab weitere Fehler: '0.9.3/compiler/cpp/src/thrifty.yy: 255.5: Fehler: ungültiges Zeichen: '*' char * strdup (const char * s) /c/University/InternetOfThings/thrift-0.9.3/compiler/cpp/src/thrifty.yy:255.14: Fehler: ungültiges Zeichen: '(' char * strdup (const char * s) ' ich its a C++ Compiler erraten, so dass es Zeiger nicht erkennt. Wie kann ich den Compiler ändern nicht-Standard-C-Code zu kompilieren? –

+1

@TonyTannous sie C-Code mit einem C++ Compiler nicht kompiliert werden. Davon abgesehen, Es gibt keinen Grund, warum ein C++ - Compiler keine Zeiger erkennt, wahrscheinlicher ist, dass er '' nicht erkennt gibt aber schlechte Fehler. – Lundin

+0

Es ist nicht ich, alles was ich tat war ./configure && make wie in der Anleitung. https://trift.apache.org/tutorial/ –

Verwandte Themen