xtensor-stack / xtensor-io

xtensor plugin to read and write images, audio files, numpy (compressed) npz and HDF5
BSD 3-Clause "New" or "Revised" License
85 stars 28 forks source link

linking error #51

Open chongyi-zheng opened 5 years ago

chongyi-zheng commented 5 years ago

I'm trying to compile a project with the xtensor-io library but I get an linking error as

usr/bin/ld: cannot find -l

I have already included

find_package(xtensor-io REQUIRED)
...
target_include_directories(... PRIVATE ${xtensor_io_INCLUDE_DIRS})
target_link_libraries(... PUBLIC xtensor-io)

in my CMakeLists.txt. However, it just didn't work.

Can someone help me?

SylvainCorlay commented 5 years ago

Could you please provide the error message?

chongyi-zheng commented 5 years ago

Oh, sorry for that.

Here are some details.

I'm currently working on a ubuntu 18.04 LTS system. I have already installed xtensor-io library into the system when I compiled source codes in directory of the project:

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
sudo make install

After that, I added the code above in my own project's CMakeLists.txt, then

cmake ..
make

errored out following messages

usr/bin/ld: cannot find -lxtensor-io
collect2: error: ld returned 1 exit status

Any suggestions?

nganhkhoa commented 5 years ago

It is stated in the README.md that this project is a header only library:

xtensor-io is a header-only library

So no library will be built, thus no linking library. The headers should be placed some where on the general include search, /usr/include, or modify your LIBRARY_PATH to contains the folder of the header files, or provide -I/path/to/xtensor-io/include/ when compiling using g++.

wolfv commented 5 years ago

yeah, this is something coming along with the new cmake stuff. ngankhoa is right, not linking xtensor-io (but rather the dependencies, like OpenImageIO, ... should help in this case).

Just adding hte xtensor-io_INCLUDES to your include directories should help.

mfouesneau commented 5 years ago

I also have linking issues when using the example from the documentation

#include <xtensor/xio.hpp>
#include <xtensor-io/xhighfive.hpp>

int main()
{
    xt::xtensor<double,2> A = xt::ones<double>({10,5});

    xt::dump_hdf5("example.h5", "/path/to/data", A);

    A = xt::load_hdf5<xt::xtensor<double,2>>("example.h5", "/path/to/data");

    std::cout << A << std::endl;

    return 0;
}

I think I compile the example properly, but I cannot get some types apparently defined somewhere. The error is below

g++ -I./include/xtensor/include -I./include/xtensor-io/include -I./include/xtensor-blas/include -I./include/xtensor-blas/include/xtensor-blas/flens -I./include -std=c++14  xtio.cpp -o xtio  -lblas -llapack -lhdf5
Undefined symbols for architecture x86_64:
  "HighFive::AtomicType<xt::uvector<double, std::__1::allocator<double> > >::AtomicType()", referenced from:
      void HighFive::SliceTraits<HighFive::DataSet>::read<xt::uvector<double, std::__1::allocator<double> > >(xt::uvector<double, std::__1::allocator<double> >&) const in xtio-ba4fba.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)