g++ compile error: undefined reference to a shared library function which exists

前端 未结 3 989
广开言路
广开言路 2021-02-19 05:15

I recently installed the hdf5 library on an ubuntu machine, and am now having trouble linking to the exported functions. I wrote a simple test script re

3条回答
  •  鱼传尺愫
    2021-02-19 06:13

    You forgot to put -lhdf5 in the compile command. Also, there's no need for -l:$HOME/hdf5/lib/libhdf5.so

    This should work: $ g++ -Wl,-rpath,$HOME/hdf5/lib -I$HOME/hdf5/include -L$HOME/hdf5/lib -lhdf5 readHDF5.cpp

提交回复
热议问题