C++ 链接器错误:未找到体系结构x86_64的ld:symbol

C++ 链接器错误:未找到体系结构x86_64的ld:symbol,c++,linker,linker-errors,C++,Linker,Linker Errors,我正试图使用Mac上的终端编译以下代码。代码是用优美的文字写成的 #include <iostream> #include <fstream> #include <vector> #include <unordered_map> #include <iomanip> #include <cmath> #include <string> #include <locale> #include <

我正试图使用Mac上的终端编译以下代码。代码是用优美的文字写成的

#include <iostream>
#include <fstream>
#include <vector> 
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <string> 
#include <locale> 
#include <cstdlib>

using namespace std;

void parse(string s, vector<string> q);

int main(int argc, char* argv[])
{

    cout << argv[1] << endl;
    cout << argv[2] << endl;
    cout << argv[3] << endl;
    cout << argv[4] << endl;

    int h = stoi(argv[1]);
    int k, c;
    string query;
    vector<string> query_words;
    if(!strcmp(argv[2], "-k"))
    {
        k = stod(argv[3]);
    }

    if(!strcmp(argv[2], "-c"))
    {
        c = stod(argv[3]);
    }


    query = argv[4];
    parse(query, query_words);

    return 0;
}


void parse(string s, vector<string> &q)
{

    string x;
    for(size_t i = 0; i < s.length(); i++)
    {
        string temp;
        if(s[i] == '_')
        {
            s[i] = ' ';
        }

        if(!isalnum(s[i]) && s[i] != ' ')
        {
            temp = s.substr(i+1, s.length() - i-1); 
            x = s.substr(0, i) +  temp;
            s = x;
            i--;
        }
    }

    int start_subString = 0;
    for(size_t i = 0; i < s.length(); i++)
    {
        if(s[i] == ' ')
        {
            string temp = s.substr(start_subString, i - start_subString);
            start_subString = i+1;
            q.push_back(temp);

        }

        if(i+1 == s.length())
        {
            string temp = s.substr(start_subString, i + 1 - start_subString);
            q.push_back(temp);

        }
    }


}
这将导致以下错误:

架构x86_64的未定义符号: “解析(std::_1::基本_字符串,std:_1::向量)”,引用自: _hits-d8b25c.o中的干管 ld:找不到架构x86_64的符号 叮当声:错误:链接器命令失败,退出代码为1(使用-v查看调用) 您声明:

void parse(string s, vector<string> q);
void解析(字符串s,向量q);
这就是它的名字。不幸的是,您定义了:

void parse(string s, vector<string> &q)
void解析(字符串s、向量&q)

这不是同一个函数,这就是为什么链接器找不到它正在寻找的函数的原因-您没有定义它。最有可能的情况是,您只需要修复声明。

请尝试
-m32
选项以获得
g++
。。。它有用吗?