Les symboles non définis pour l'architecture x86_64: ... “_main”, référencé à partir de: implicite d'entrée/de départ pour l'exécutable principal

Yak-rasage alerte.

Même si je suis empêché d'afficher le code source, je figure avec un bien écrit post, je peut être en mesure de fournir suffisamment d'informations pour obtenir de l'aide. Les étapes que j'ai essayé ci-dessous ont tous été recueilli à partir d'autres postes, et c'est devenu un peu circulaire maintenant.

Je suis sur OS X avec les éléments suivants:

MacBook-Pro-de-Pyderman:Metaphone3 Pyderman$ which g++
/usr/bin/g++
MacBook-Pro-de-Pyderman:Metaphone3 Pyderman$ arch
i386
MacBook-Pro-de-Pyderman:Metaphone3 Pyderman$ g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr     
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
MacBook-Pro-de-Pyderman:Metaphone3 Pyderman$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr     
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
MacBook-Pro-de-Pyderman:Metaphone3 Pyderman$ clang++ --version
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
MacBook-Pro-de-Pyderman:Metaphone3 Pyderman$ brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: edcf1d119c4ca9d79d7147a684b7d74767cbb1f6
Last commit: 6 weeks ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: dual-core 64-bit penryn
OS X: 10.9.5-x86_64
Xcode: N/A
CLT: 6.2.0.0.1.1424975374
Clang: 6.0 build 600
X11: 2.7.7 => /opt/X11
System Ruby: 2.0.0-p481
Perl: /usr/bin/perl
Python: /Library/Frameworks/Python.framework/Versions/2.7/bin/python => /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: 1.6.0_65-b14-468

Je suis donc donné trois fichiers:

  • Metaphone3.cpp
  • Metaphone3ExampleCode.cpp
  • Metaphone3.h

J'essaie de compiler avec g++:

g++ Metaphone3.cpp

J'obtiens:

Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
  • gcc et clang++ le même rapport.
  • L'ajout d'-m32 n'a aucun effet.
  • g++ Metaphone3.cpp -I /usr/local/include n'a pas d'effet

Si j'essaie:

g++ -Wall -c Metaphone3.cpp

Cela se débarrasser de l'avertissement, et un Metaphone3.o et Metaphone se produit.

Si j'essaie de l'exécuter:

MacBook-Pro-de-Pyderman:Metaphone3 Pyderman$ ./Metaphone
-bash: ./Metaphone: Malformed Mach-o file

Un peu plus de recherche indique que j'ai peut-être raté une étape de liaison. Donc:

gcc Metaphone3.o -o Metaphone3

Mais cela me ramène à l'origine de l'erreur.

D'autres postes, puis de suggérer la suppression de la -c drapeau, mais c'est ce drapeau qui m'a permis d'obtenir transmis à l'erreur. Donc vous pouvez voir comment cela est arriver circulaire. Comme vous l'avez peut être la collecte de maintenant, je suis un développeur, mais pas un développeur C++, et à venir, de Python, de la compilation est un monde nouveau pour moi. Toute et toute aide est appréciée

  • g++ -Wall -c Metaphone3.cpp ne doit être génératrice de Metaphone.o et rien d'autre
InformationsquelleAutor Pyderman | 2015-11-03