-1

This is for a Mac using Eclipse

#include <iostream>
using namespace std;

int main() {
 cout << "!!!Hello, world!!!" << endl;
 return 0;
}

Here is the compiler output:

Invoking: MacOS X C++ Linker g++ -o "Lab2" ./secondlab.o
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)
make: *** [Lab2] Error 1
Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
B. Marien
  • 11
  • 1
  • `clang` or `clang++`? Anyway, welcome to [so]. Please visit the [ask] help pages. Your question is very low on required details. – StoryTeller - Unslander Monica Sep 17 '18 at 15:50
  • How does the compiler command line look? – πάντα ῥεῖ Sep 17 '18 at 15:50
  • This is the full error: Invoking: MacOS X C++ Linker g++ -o "Lab2" ./secondlab.o 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) make: *** [Lab2] Error 1 – B. Marien Sep 17 '18 at 15:57
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Alan Birtles Sep 17 '18 at 16:02
  • I am unsure why I am getting this error, i am new to coding and cant figure it out, i did not have this issue when completing my last lab with the same IDE and compiler – B. Marien Sep 17 '18 at 16:03
  • Are you sure that source is actually part of your project? – πάντα ῥεῖ Sep 17 '18 at 16:04
  • Possible duplicate of [What does the compile-time error "Undefined symbols for architecture x86\_64" mean?](https://stackoverflow.com/q/8439664/608639) – jww Sep 17 '18 at 16:53
  • It can't find your `main()` function because you haven't added the name of the file that you show into the compilation/link command. If your program that you show is in a file called `fred.cpp` you need to add `fred.cpp` to your `g++` command. – Mark Setchell Sep 18 '18 at 19:18

1 Answers1

-2

All you need to do is configure the C++ Linker correctly under CDT/eclipse one has to enter "sndfile" in the text field found under:

Project->Properties->C/C++ Build->Settings->Mac OS C++ Linker->Libraries->"Libraries -l"

The "-l" gets added to "sndfile" automatically to create "-lsndfile"

It is also important however to point the Compiler to the correct include directory (containing "sndfile.h"). I guess most installations would install this into "/usr/local/include". For a C++ project in CDT/eclipse, this would need to be entered in

Project->Properties->C/C++ Build->Settings->GCC C++ Compiler->Includes->"Include paths (-l)"

And please do take a look at this thread.

handlerFive
  • 870
  • 10
  • 23
  • 2
    Please don't just post a link as an answer, links expire then your answer becomes meaningless, post the important parts of your link inside your answer. – Alan Birtles Sep 17 '18 at 16:06