0

I am doing different exercises in c++ for preparing my exam at university. I am pretty sure they are all without heavy mistake and should complement.

All codes can't complement with the same error log:

Undefined symbols for architecture x86_64:

[hundreds lines of error log]

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The error log between is about every single line of code.

I am wondering if I've missed to install some package for complement c++ on my device.

Code Example:

#include <iostream>
#include <new>

int main () {

int n;

std::cout<<"How many value do you want to enter to your list?"<< std::endl;
std::cin>>n;

int* numbArray = new int[n];

for(int i = 0; i<n; i++) {

    std::cout<<"Enter the"<< i+1 <<". value!"<<std::endl;
    std::cin>>numbArray[i];
}

std::cout << "List of value: " << std::endl;
for(int i=0; i<n; i++ ) {

    std::cout<<numbArray[i]<<" "<<std::endl;

}

std::cout<<"end of arrays"<<std::endl;


delete[]numbArray;

return 0;

}

My operating System is macOS Catalina 10.15.2

Thanks for your help.

Shebuka
  • 3,148
  • 1
  • 26
  • 43
VomDorfe
  • 51
  • 2
  • 5
  • It would be helpful to show _which_ symbols exactly are missing. However, this is most likely a problem with your compiler/toolchain installation. Maybe try reinstalling it. – Erlkoenig Jan 15 '20 at 09:06
  • No explicit symbol is missing, the error lines look like this, for every single line of code: `"std::__1::basic_ostream >::operator<<(int)", referenced from: _main in Array_main-23713d.o` I use the Terminal as a compiler. – VomDorfe Jan 15 '20 at 09:16
  • 1
    There are no explicit/implicit linker symbols. This is a symbol in the C++ standard library. How to you call the compiler and linker? Do you happen to link with "gcc" instead of "g++", as it should be? – Erlkoenig Jan 15 '20 at 09:18
  • I used "gcc", just as my exercise Sheed said. But now works with "g++". Didn't know, thanks for helping. – VomDorfe Jan 15 '20 at 09:23
  • Does this answer your question? [What's the difference between gcc and g++/gcc-c++?](https://stackoverflow.com/questions/5853664/whats-the-difference-between-gcc-and-g-gcc-c) – Erlkoenig Jan 15 '20 at 09:29
  • Yes, you helped! Thanks – VomDorfe Jan 15 '20 at 09:29

1 Answers1

0

There are no explicit/implicit linker symbols. This is a symbol in the C++ standard library. How to you call the compiler and linker? Do you happen to link with "gcc" instead of "g++", as it should be?

Just as Erlkoeing said, using "g++" instead of "gcc" for calling the compiler and linker works fine.

VomDorfe
  • 51
  • 2
  • 5