Giter VIP home page Giter VIP logo

Comments (6)

vasild avatar vasild commented on August 16, 2024

Hello,

Post here the full command and full output of how you compiled the ipfs library, as well as the output of nm --demangle ./lib/libipfs-http-client.so

from cpp-ipfs-http-client.

tict2019 avatar tict2019 commented on August 16, 2024

I use Ubuntu 18.04.4 LTS
I have already installed dependencies including:
-gcc,c++,g++: version 7.5.0
-Curl: download source and install (./configure && make && make install)
-JSON: download Json from github
-Cmake version 3.15.2. Compiled as the guidance of the following link: https://vasild.github.io/cpp-ipfs-http-client/
After finishing the installation, in the folder installed, having two folders: include, lib.
Then, I create the file myprog.cc as the guidance in this folder. And compile with the command:
c++ -std=c++11 -I./include -L./lib -lipfs-http-client myprog.cc -o myprog
The full output is:

/tmp/cctPIZ8r.o: In function `main':
myprog.cc:(.text+0x4f): undefined reference to `ipfs::Client::Client(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long)'
myprog.cc:(.text+0x78): undefined reference to `ipfs::Client::~Client()'
collect2: error: ld returned 1 exit status

I also attach the file containing the full output of the command: nm --demangle ./lib/libipfs-http-client.so
nm_command.txt
And the file myprog.cc
myprog.cc.txt
Thank you very much for your help!!!

from cpp-ipfs-http-client.

vasild avatar vasild commented on August 16, 2024

Your library seems to be healthy (based on the nm output), it should link. Try to provide the shared library directly: c++ -std=c++11 -I./include ./lib/libipfs-http-client.so myprog.cc -o myprog. Or build a static library and try to link with it cmake -DBUILD_SHARED_LIBS:BOOL=OFF ....

from cpp-ipfs-http-client.

tict2019 avatar tict2019 commented on August 16, 2024

I have already run in the two ways, but can't solve these errors.
can you give me the installation guidance (maybe on Debian, Centos, Windows, ..)?
Thank you!

from cpp-ipfs-http-client.

vasild avatar vasild commented on August 16, 2024

This works for me (curl is installed system-wide in /usr/local):

~$ mkdir /tmp/ipfs
~$ cd /tmp/ipfs
/tmp/ipfs$ git clone https://github.com/vasild/cpp-ipfs-http-client.git
/tmp/ipfs$ git clone https://github.com/nlohmann/json.git
/tmp/ipfs$ mkdir build

# build static library

/tmp/ipfs$ cd build
/tmp/ipfs/build$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/ipfs/install -DJSON_FOR_MODERN_CXX_INCLUDE_DIR:PATH=/tmp/ipfs/json/include ../cpp-ipfs-http-client
/tmp/ipfs/build$ make -j4
/tmp/ipfs/build$ make install
/tmp/ipfs/build$ ls -l /tmp/ipfs/install/lib/
-rw-r--r--  1 vd  vd     1803892 Mar 25 10:53 libipfs-http-client.a
/tmp/ipfs/build$ cd ..
/tmp/ipfs$ cat > myprog.cc <<EOF
> #include "ipfs/client.h"
>
> int main(int argc, char** argv) {
>   ipfs::Client a("localhost", 5001);
>   return 0;
> }
> EOF
/tmp/ipfs$ c++ -std=c++11 -I./json/include -I./install/include -L./install/lib -L/usr/local/lib -lipfs-http-client -lcurl myprog.cc -o myprog

# build shared library

/tmp/ipfs$ rm -fr build/* install
/tmp/ipfs$ cd build
/tmp/ipfs$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/ipfs/install -DJSON_FOR_MODERN_CXX_INCLUDE_DIR:PATH=/tmp/ipfs/json/include -DBUILD_SHARED_LIBS:BOOL=ON ../cpp-ipfs-http-client
/tmp/ipfs$ make -j4
/tmp/ipfs$ make install
/tmp/ipfs/build$ ls -l /tmp/ipfs/install/lib/
lrwxr-xr-x  1 vd  vd           24 Mar 25 11:00 libipfs-http-client.so -> libipfs-http-client.so.0
lrwxr-xr-x  1 vd  vd           28 Mar 25 11:00 libipfs-http-client.so.0 -> libipfs-http-client.so.0.4.0
-rwxr-xr-x  1 vd  vd       986664 Mar 25 11:00 libipfs-http-client.so.0.4.0
/tmp/ipfs$ c++ -std=c++11 -I./json/include -I./install/include -L./install/lib -lipfs-http-client myprog.cc -o myprog

You must be doing something different or your system is somehow broken.

Good luck!

from cpp-ipfs-http-client.

tict2019 avatar tict2019 commented on August 16, 2024

The Errors have solved. maybe my system is broken.
I used "# build shared library" and before running the command ./myprog
I execute the command: export LD_LIBRARY_PATH=/tmp/ipfs/install/lib/
Thank you very much!

from cpp-ipfs-http-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.