Compiler Error : Undefined symbols for architecture x86_64
userM7Lh5621CD0P opened this issue · 0 comments
userM7Lh5621CD0P commented
using ssdb for long time but with php client. fine in most cases, but there is something I have to iterate many many times .. and with C/C++ I should be able to save a lot of time ..
Compiler failed with error Undefined symbols for architecture x86_64
macOS 10.15.6 Catalina
g++-11 --version
g++-11 (Homebrew GCC 11.2.0_3) 11.2.0
I have followed the steps in the doc readme
g++ -o hello-ssdb -I<path of api/cpp> hello-ssdb.cpp <path of api/cpp>/libssdb-client.a
error :
g++ -o hello-ssdb -I<path of api/cpp> hello-ssdb.cpp <path of api/cpp>/libssdb-client.a
..in libssdb-client.a(SSDB_impl.o)
..in libssdb-client.a(link.o)
ld: symbol(s) not found for architecture x86_64
g++ -o hello-ssdb.cpp hello-ssdb libssdb-client.a
ld: can't link with a main executable file
g++ -o hello-ssdb hello-ssdb.cpp
Undefined symbols for architecture x86_64:
"__ZN4ssdb6Client7connectEPKci", referenced from:
_main in cciJLzzz.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
.cpp
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include "SSDB_client.h"
int main(int argc, char **argv){
const char *ip = (argc >= 2)? argv[1] : "127.0.0.1";
int port = (argc >= 3)? atoi(argv[2]) : 8888;
ssdb::Client *client = ssdb::Client::connect(ip, port);
if(client == NULL){
printf("fail to connect to server!\n");
}else{
printf("ssdb client\n");
}
delete client;
return 0;
}
I would like to connect to the ssdb server ..
I also asked stackoverflow