Reputation: 41
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!
Upvotes: 0
Views: 6918
Reputation: 11
in my case, the problem was solved when I change the Cmake version to 2.9
Upvotes: 0
Reputation: 11
Try this:
g++ -std=c++11 -I./ -I./contrib -L./build/clickhouse/ -lclickhouse-cpp-lib-static -o demo demo.cpp ./build/clickhouse/libclickhouse-cpp-lib-static.a ./build/contrib/lz4/liblz4-lib.a ./build/contrib/cityhash/libcityhash-lib.a ./build/contrib/absl/libabsl-lib.a
Upvotes: -1
Reputation: 118292
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
.
Upvotes: 2