This question has already been here so many times. But I didn't find the answer.
I have this .cpp
file
#include <clickhouse/client.h>
#include <iostream>
using namespace clickhouse;
int main(){
/// Initialize client connection.
Client client(ClientOptions().SetHost("localhost"));
client.Select("SELECT l.a, l.b from table", [] (const Block& block)
{
for (size_t i = 0; i < block.GetRowCount(); i) {
std::cout << block[0]->As<ColumnUInt64>()->At(i) << " "
<< block[1]->As<ColumnString>()->At(i) << "\n";
}
}
);
return 0;
}
and I have instantiated SO library, like written here.
after that i got the following structure of /usr/local/lib directory
:
~/$ ls /usr/local/lib
>>libclickhouse-cpp-lib-static.a libclickhouse-cpp-lib.so
in next step I trying execute compilation with g
~/$ g run.cpp -std=c 17 -o result -llibclickhouse-cpp-lib -L/usr/local/lib
>>/usr/bin/ld: cannot find -llibclickhouse-cpp-lib
>>collect2: error: ld returned 1 exit status
I don't know what hinders create links.
thank You for Your help!
CodePudding user response:
ld
's manual page describes the -l
option as follows (irrelevant details omitted):
-l namespec
--library=namespec
Add the archive or object file specified by namespec to the list of files to link. [...] ld will search a directory for a library called libnamespec.so
If you read this very carefully, you will reach the conclusion that -llibclickhouse-cpp-lib
instructs ld
to search for a library named liblibclickhouse-cpp-lib.so
which, obviously, does not exist.
This should simply be -lclickhouse-cpp-lib
.