gcc ld: symbol(s) not found for architecture x86_64
Okay also ich mache einen lexer und einen parser mit Ocamlyacc. Ich habe meine Forschung getan, und ich denke, dass es etwas zu tun mit meinem makefile nicht die Wahl der richtigen bit-version für meinen compiler oder etwas ähnliches? Ich weiß nicht viel über makefiles, das ist der Grund, warum ich Frage.
Ich habe mein Programm auf einen anderen computer, wo funktioniert es ohne Probleme, also es muss irgendwas mit meinem Rechner.
Es ist ein MacBook Pro (64-bit. Ich bin mit Xcode 4.2.1.
Hier die makefile:
SHELL = /bin/sh
C_C = gcc
CPP_C = g++
ifdef GPROF
C_CPP_FLAGS = -pg -O3
else
ifndef DEBUG
C_CPP_FLAGS = -O3
else
C_CPP_FLAGS = -g
endif
endif
C_LD = $(C_C)
CPP_LD = $(CPP_C)
C_YACC = bison
C_LEX = flex
AR = ar
RANLIB = ranlib
OCAML_C = ocamlc
OCAML_OPT_C = ocamlopt
ifdef GPROF
OCAML_C_FLAGS = -dtypes
OCAML_OPT_C_FLAGS = -dtypes
OCAML_LD = $(OCAML_C) -g
OCAML_OPT_LD = $(OCAML_OPT_C) -p
else
ifndef DEBUG
OCAML_C_FLAGS = -dtypes
OCAML_OPT_C_FLAGS = -dtypes
OCAML_LD = $(OCAML_C) -g
OCAML_OPT_LD = $(OCAML_OPT_C)
else
OCAML_C_FLAGS = -dtypes
OCAML_OPT_C_FLAGS = -dtypes
OCAML_LD = $(OCAML_C) -g
OCAML_OPT_LD = $(OCAML_OPT_C)
endif
endif
OCAML_MKTOP = ocamlmktop
OCAML_CP = ocamlcp
OCAML_DEP = ocamldep
OCAML_LEX = ocamllex
OCAML_YACC = ocamlyacc
OCAML_C_CPP_INC = -I $(shell $(OCAML_C) -v | tail -1 | sed -e \
's/^Standard library directory: //')
Den Fehler, dass ich bekomme ist:
ld: symbol(s) not found for architecture x86_64
Hier die vollständige Ausgabe:
make
Linking OCAML (top level) program nanoml.top
ocamlmktop -o nanoml.top -custom nano.cmo nanoLex.cmo nanoParse.cmo main.cmo \
-cc g++ -cclib ' '
/var/folders/n3/jgblhwmj40lchgq71bmgr8sw0000gn/T/camlprimbd6a63.c:784: warning: deprecated conversion from string constant to ‘char*’
.
. //The same line ALOT of times. Removed due to limit of chars in a single post.
.
/var/folders/n3/jgblhwmj40lchgq71bmgr8sw0000gn/T/camlprimbd6a63.c:784: warning: deprecated conversion from string constant to ‘char*’
ld: warning: ignoring file /usr/local/lib/ocaml/libcamlrun.a, file was built for archive which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
"_caml_alloc_dummy", referenced from:
_caml_builtin_cprim in ccZbZ9Mf.o
.
. //And many of these lines
.
"_caml_get_exception_backtrace", referenced from:
_caml_builtin_cprim in ccZbZ9Mf.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
File "_none_", line 1, characters 0-1:
Error: Error while building custom runtime system
make: *** [nanoml.top] Error 2
Vielen Dank im Voraus!
BEARBEITEN:
Ich bin nur mit Ocaml. Kein C++ oder C, die verknüpft werden muss mit es. Ich habe nie versucht, mit meinem ocaml-code mit einem makefile vor, aber ich kann laufen, andere ocaml-code auf diesem computer. Dies ist das erste mal, es schlägt fehl, aber es ist das erste mal, dass ich ein makefile.
Und das gleiche makefile und der code funktioniert auf anderen Maschinen(ältere Maschinen aber) also ich denke es hat etwas mit diesem zu tun mit 64-bit.
Ich gefunden habe ich gegeben, einem anderen makefile, das wie folgt aussieht:
# Generic compilation rules
%.o : %.c
@echo Compiling C file $<
$(C_C) $(C_CPP_FLAGS) $(C_CPP_INCLUDES) -c $< -o $@
%.o : %.cc
@echo Compiling C++ file $<
$(CPP_C) $(C_CPP_FLAGS) $(C_CPP_INCLUDES) -c $< -o $@
%.o : %.cpp
@echo Compiling C++ file $<
$(CPP_C) $(C_CPP_FLAGS) $(C_CPP_INCLUDES) -c $< -o $@
%.cmi: %.mli
@echo Compiling OCAML interface $<
$(OCAML_C) $(OCAML_C_FLAGS) $(OCAML_INCLUDES) -c $< -o $@
%.cmo: %.ml
@echo Compiling \(to byte code\) OCAML module $<
$(OCAML_C) $(OCAML_C_FLAGS) $(OCAML_INCLUDES) -c $< -o $@
%.cmx: %.ml
@echo Compiling \(to native code\) OCAML module $<
$(OCAML_OPT_C) $(OCAML_OPT_C_FLAGS) $(OCAML_INCLUDES) -c $< -o $@
%.ml: %.mll
@echo Lexing OCAML file $<
$(OCAML_LEX) $<
%.ml %.mli: %.mly
@echo Yaccing OCAML file $<
$(OCAML_YACC) $<
# Generic cleaning rules
default-clean:
rm -f *~ *.o *.cmo *.cmx .*.depend *.cmi
.PHONY: default-clean
# Generic link rules and library creation rules
#
# These rules assume that the following variables are set (when necessary):
#
# - C_EXE : name of the C executable
# - CPP_EXE : name of the C++ executable
# - OCAML_EXE : name of the OCaml executable (without suffix)
# - OCAML_TPL_EXE : name of the OCaml custom toplevel (without suffix)
# - C_CPP_LIB : name of the C/C++ library
# - OCAML_LIB : name of the OCaml library (without suffix)
# - C_CPP_EXE_OBJ : list of C/C++ objects (without suffix) to build exe
# - OCAML_EXE_OBJ : list of OCaml modules (without suffix) to build exe
# - C_CPP_LIB_OBJ : list of C/C++ objects (without suffix) to build lib
# - OCAML_LIB_OBJ : list of OCaml modules (without suffix) to build lib
# - C_CPP_LD_FLAGS : C and C++ linker flags
# - OCAML_LD_FLAGS : OCaml linker (both native and bytecode) flags
# - C_CPP_LD_LIBS : C and C++ linker libraries
# - OCAML_LD_LIBS : OCaml linker (both native and bytecode) libraries
ifdef C_EXE
$(C_EXE): $(C_CPP_EXE_OBJ:%=%.o)
@echo Linking C program $@
$(C_LD) $(C_CPP_LD_FLAGS) -o $@ $(C_CPP_EXE_OBJ:%=%.o) $(C_CPP_LD_LIBS)
endif
ifdef CPP_EXE
$(CPP_EXE): $(C_CPP_EXE_OBJ:%=%.o)
@echo Linking C++ program $@
$(CPP_LD) $(C_CPP_LD_FLAGS) -o $@ $(C_CPP_EXE_OBJ:%=%.o) $(C_CPP_LD_LIBS)
endif
ifdef C_CPP_LIB
$(C_CPP_LIB).a: $(C_CPP_LIB_OBJ:%=%.o)
@echo Creating C/C++ library $@
$(AR) r $@ $?
$(RANLIB) $@
endif
ifdef OCAML_EXE
$(OCAML_EXE).byte: $(C_CPP_EXE_OBJ:%=%.o) $(OCAML_EXE_OBJ:%=%.cmo)
@echo Linking OCAML \(byte code\) program $@
$(OCAML_LD) $(OCAML_LD_FLAGS) -o $@ -custom $(OCAML_LD_LIBS:%=%.cma) $(C_CPP_EXE_OBJ:%=%.o) $(OCAML_EXE_OBJ:%=%.cmo) \
-cc $(CPP_C) -cclib '$(C_CPP_LD_FLAGS) $(C_CPP_LD_LIBS)'
$(OCAML_EXE).opt: $(C_CPP_EXE_OBJ:%=%.o) $(OCAML_EXE_OBJ:%=%.cmx)
@echo Linking OCAML \(native code\) program $@
$(OCAML_OPT_LD) $(OCAML_LD_FLAGS) -o $@ $(OCAML_LD_LIBS:%=%.cmxa) $(C_CPP_EXE_OBJ:%=%.o) $(OCAML_EXE_OBJ:%=%.cmx) \
-cc $(CPP_C) -cclib '$(C_CPP_LD_FLAGS) $(C_CPP_LD_LIBS)'
$(OCAML_EXE).top: $(C_CPP_EXE_OBJ:%=%.o) $(OCAML_EXE_OBJ:%=%.cmo)
@echo Linking OCAML \(top level\) program $@
$(OCAML_MKTOP) $(OCAML_LD_FLAGS) -o $@ -custom $(OCAML_LD_LIBS:%=%.cma) $(C_CPP_EXE_OBJ:%=%.o) $(OCAML_EXE_OBJ:%=%.cmo) \
-cc $(CPP_C) -cclib '$(C_CPP_LD_FLAGS) $(C_CPP_LD_LIBS)'
endif
ifdef OCAML_TPL_EXE
$(OCAML_TPL_EXE).byte: $(C_CPP_EXE_OBJ:%=%.o) $(OCAML_EXE_OBJ:%=%.cmo)
@echo Linking OCAML \(byte code\) toplevel $@
$(OCAML_MKTOP) $(OCAML_LD_FLAGS) -o $@ -custom $(OCAML_LD_LIBS:%=%.cma) $(C_CPP_EXE_OBJ:%=%.o) $(OCAML_EXE_OBJ:%=%.cmo) \
-cc $(CPP_C) -cclib '$(C_CPP_LD_FLAGS) $(C_CPP_LD_LIBS)'
endif
ifdef OCAML_LIB
$(OCAML_LIB).cma: $(OCAML_LIB_OBJ:%=%.cmo)
@echo Creating OCAML \(byte code\) library $@
$(OCAML_LD) $(OCAML_LD_FLAGS) -a -o $@ $(OCAML_LIB_OBJ:%=%.cmo)
$(OCAML_LIB).cmxa $(OCAML_LIB).a: $(OCAML_LIB_OBJ:%=%.cmx)
@echo Creating OCAML \(native code\) library $@
$(OCAML_OPT_LD) $(OCAML_LD_FLAGS) -a -o $@ $(OCAML_LIB_OBJ:%=%.cmx)
endif
ifdef OCAML_CINTF
ifdef OCAML_BYTECODE_CINTF
$(OCAML_CINTF).o: $(OCAML_CINTF_OBJ:%=%.cmo)
@echo Creating OCAML \(native code\) C interface library $@
$(OCAML_LD) $(OCAML_LD_FLAGS) -output-obj -o $@ $(OCAML_LD_LIBS:%=%.cma) $(OCAML_CINTF_OBJ:%=%.cmo)
$(OCAML_CINTF_LIB).a: $(OCAML_CINTF).o $(C_CPP_CINTF_OBJ:%=%.o)
@echo Creating C/C++ interface library $@
$(AR) r $@ $?
$(RANLIB) $@
else
$(OCAML_CINTF).o: $(OCAML_CINTF_OBJ:%=%.cmx)
@echo Creating OCAML \(native code\) C interface library $@
$(OCAML_OPT_LD) $(OCAML_LD_FLAGS) -output-obj -o $@ $(OCAML_LD_LIBS:%=%.cmxa) $(OCAML_CINTF_OBJ:%=%.cmx)
$(OCAML_CINTF_LIB).a: $(OCAML_CINTF).o $(C_CPP_CINTF_OBJ:%=%.o)
@echo Creating C/C++ interface library $@
$(AR) r $@ $?
$(RANLIB) $@
endif
endif
# Generic dependencies creation rules
.%.mli.depend: %.mli
@echo Generating dependencies for OCAML interface $<
$(OCAML_DEP) $< > $@
.%.ml.depend: %.ml
@echo Generating dependencies for OCAML module $<
$(OCAML_DEP) $< > $@
Du musst angemeldet sein, um einen Kommentar abzugeben.
Die interessante Zeile ist
Er sagt Ihnen, dass Ihr ocaml-runtime ist wahrscheinlich ein 32-bit-Bibliothek, statt
die 64 bits, die Sie brauchen.
Möchten Sie vielleicht versuchen Sie die "-m32" - flag des g++ zu kompilieren alles in 32 bit, oder installieren Sie ein 64-bit-version von ocaml.
ld: symbol(s) not found for architecture i386
😀 😀 😀Sieht es aus wie vielleicht Ihr OCaml-compiler ist die Herstellung von 32-bit-Programme. Ein Weg, zu sagen ist zu sagen:
Wenn Sie sehen
architecture i386
, es ist ein 32-bit-compiler. Wenn Sie sehenarchitecture amd64
, es ist ein 64-bit-compiler. Jedenfalls sind die beiden anderen Werte sehe ich auf meinem Macbook Pro.Bearbeiten
Den
Makefile
Sie geben nicht wirklich beschreiben, was Sie zu tun versuchen. Es ist nur definiert Namen für einige Sprache-Prozessoren. Die realMakefile
ist möglicherweise auch andernorts.Da die
Makefile
nicht wirklich sagen, was Sie tun, merkte ich, dass ich sehe keine Beweise, die Sie verknüpfen, OCaml und C++ (oder C) zusammen. Die erste Zeile der Ausgabe muss nicht alles zeigen, außer das, was aussieht wie OCaml-Dateien. Darüber hinaus sind Siebenannt
xyz.cmo
, die bytecode OCaml-Dateien. Das heißt, Sie sind nicht 32-bit - oder 64-bit (native) Dateien.Haben Sie einige C++ und einige OCaml-Komponenten müssen miteinander verbunden werden, oder ist euer Projekt rein OCaml? Wenn es rein OCaml, ich würde sagen, das problem ist, alle in der
Makefile
. Sie sollten sich nicht sorgen zu machen über die Architektur, wenn Sie wollen einfach nur zu laufen OCaml-code.Wenn es für einige C++ oder C, dann müssen Sie es kompilieren mit
-arch i386
(um 32-bit-Objekte) und dann verknüpfen Sie alles zusammen mit einem linker (ld
), der weiß, dass es die Herstellung eines 32-bit-Ziel. (Oder, wie Fabrice Le Fessant sagt, Sie könnten installieren Sie ein 64-bit-OCaml-compler.)Einen möglichen Vorschlag ist die Erstellung einer kleinen OCaml-Datei und sehen, wenn Sie kompilieren und führen Sie es.
Mithilfe des bytecode-compiler, sieht es wie folgt aus:
Mithilfe einer nativen 32-bit-compiler, sieht es wie folgt aus:
Edit 2
Ihre zweite makefile noch nicht zeigen, was Sie zu tun versuchen, speziell. Es ist nur definiert einige Regeln zum kompilieren und verknüpfen verschiedene Arten von ausführbaren Dateien. Jedoch, da Sie sagen, dass Ihr Projekt alle OCaml, dann würde ich sagen, das ganze problem ist in diesem Makefile.
Das problem scheint zu sein, dass dieses Makefile gibt an, welcher C-compiler und den Bibliotheken der OCaml-compiler verwenden soll als back-end mithilfe der
-cc
und-cclib
Optionen. Auf den meisten Systemen, wird es funktionieren, mit OK geben Sie einfach die standard-C-compiler back-end für OCaml. Auf Mac OS X, 32-bit/64-bit-Architektur Komplikationen. Da kannst du kompilieren OCaml erfolgreich ohne dieses Makefile, ich würde vorschlagen, dass der OCaml-compiler bereits weiß, wie zu kompilieren und verknüpfen-OCaml-Programme. So könnten Sie versuchen, entfernen nur die-cc
und-cclib
Optionen aus der Datei Makefile.Dazu: In allen drei Abschnitten unter
OCAML_EXE
entfernen Sie auch die Dritte Zeile komplett (die Zeile mit-cc
und-cclib
), und entfernen Sie den umgekehrten Schrägstrich auf der vorherigen Zeile.cc -arch i386
für mich funktioniert.-arch i386
(oder gleichwertig) auf den link Schritt auch.Ich habe mit diesem problem seit den letzten zwei Tagen beim Versuch zu kompilieren gphoto2. Ich habe vor kurzem ein Upgrade von OS X 10.8 und OS X 10.9. Zuerst dachte ich, es würde zu Problemen auf dem neuen XCode-version und die Kommandozeilen-tools.
Machte ich sicher, dass alles zu aktualisieren, aber die Architektur Inkonsistenz auf ocaml war immer noch da, also habe ich beschlossen zu installieren, der homebrew-version von ocaml:
et voilà