Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

Eclipse "ld: symbol(s) not found for architecture x86_64" Error

This is simple and idk what is going on
I am coding on my mac sierra
Code
#include <iostream>
#include <string>
using namespace std;

int main() {
    
    int name = "";
    cout << "What is your name traveller?\n";
    cin >> name;
    
    return 0;
}
Error
Code
make all
Building target: FirstProject
Invoking: MacOS X C++ Linker
g++  -o "FirstProject"  ./FirstProgram.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: *** [FirstProject] Error 1
Help
Hard to say since you're not showing your makefile. You likely already linked it already in the makefile. But you can just compile with g++ -o FirstProject FirstProject.cpp. You don't need a makefile for simply playing around as you seem to be. You will need to fix your syntax error first, though: int name -> string name. You also don't need to initialize it to an empty string because the constructor already does that. Consider removing "using namespace std;" also, as you don't want to be polluting the global namespace. It can lead to conflicts in name resolution. Hence, it is considered bad practice. You can declare namespaces within the scope of a function, as in the example below, but for the "std" namespace, you're better off not declaring it and just using the scope resolution operator (::).

Code
namespace DES
{
    unsigned int DES(unsigned int message, unsigned int key, Feistel::transformCallback transform, Feistel::mode::value cryptMode)
    {
        using namespace Feistel;
        
        message = rotateLeft(message, 4);    // This is Feistel::rotateLeft().
        registers regs(message);    // Feistel::registers
    
        if(cryptMode == mode::DECRYPT)
            permute(regs);    // Feistel::permute(), etc.
        
        for(int i = 0; i < 2; ++i)
            round(regs, subkey(key, i, cryptMode), transform, cryptMode);
    
        if(cryptMode == mode::ENCRYPT)
            permute(regs);
        
        unsigned int C = (regs.L << 2) | regs.R;    // Concatenate registers.
        return rotateRight(C, 4);
    }

// ....

}
[Image: 8Yoto.png]
What's the name of your file? Looks like you're using an object file "./FirstProgram.o" in your command line, is your source file "FirstProgram.c"?
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]


Possibly Related Threads...
Thread / Author Replies Views Last Post
by Phantom_NiNjaJul 31, 2025 10:22 PM 0 115 Jul 31, 2025 10:22 PM
Last Post: Phantom_NiNja
by HackersApr 14, 2024 12:50 PM 14 675 Apr 14, 2024 12:50 PM
Last Post: Hackers
[C] by lo0srMar 23, 2022 10:40 PM 14 762 Mar 23, 2022 10:40 PM
Last Post: rathvncgod