Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to `hdt::HDTManager::mapHDT(char const*, hdt::ProgressListener*)' #271

Open
KonradHoeffner opened this issue Jan 16, 2023 · 0 comments

Comments

@KonradHoeffner
Copy link

KonradHoeffner commented Jan 16, 2023

I followed the documentation exactly but I cannot compile any of the examples after installing the current dev branch:

./autogen.sh
./configure
make -j2
sudo make install
[...]
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'
[...]

I also added /usr/local/lib to a new file /etc/ld.so.conf.d/hdtcpp.conf and executed sudo ldconfig.

$ g++ -I/usr/local/include -L/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib search.cpp
/usr/bin/ld: /tmp/ccy8i6RF.o: in function `main':
search.cpp:(.text+0x20): undefined reference to `hdt::HDTManager::mapHDT(char const*, hdt::ProgressListener*)'
collect2: error: ld returned 1 exit status

The code of search.cpp is taken from https://www.rdfhdt.org/manual-of-the-c-hdt-library/:

#include <iostream>
#include <HDTManager.hpp>
 
using namespace std;
using namespace hdt;
 
int main(int argc, char *argv[]) {
 
    // Load HDT file (Use mapIndexedHDT if you plan to use ?p?, ?po or ??o queries.
    HDT *hdt = HDTManager::mapHDT("data/test.hdt");
 
    // Enumerate all triples matching a pattern ("" means any)
    IteratorTripleString *it = hdt->search("http://example.org/uri3","","");
    while(it->hasNext()){
        TripleString *triple = it->next();
        cout << triple->getSubject() <<
        ", " << triple->getPredicate() <<
        ", " << triple->getObject() << endl;
    }
    delete it; // Remember to delete iterator to avoid memory leaks!
    delete hdt; // Remember to delete instance when no longer needed!
}

I am very inexperienced with C++ so this may be something basic that is not written in the docs that experienced C++ programmers know already.
In case this is not a bug, I would be very glad if you could explain the problem in terms that a beginner C++ programmer can understand.

The HDT libraries seem to exist in /usr/local/lib:

$ ls /usr/local/lib 
libcds.a  libcds.la  libcds.so  libcds.so.0  libcds.so.0.0.0  libhdt.a  libhdt.la  libhdt.so  libhdt.so.0  libhdt.so.0.0.0  pkgconfig

verbose

$ g++ -v -I/usr/local/include -L/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib search.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-I' '/usr/local/include' '-L/usr/local/lib' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/cc1plus -quiet -v -I /usr/local/include -D_GNU_SOURCE search.cpp -quiet -dumpdir a- -dumpbase search.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -version -o /tmp/ccm8ymhR.s
GNU C++17 (GCC) version 12.2.0 (x86_64-pc-linux-gnu)
	compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP

warning: MPFR header version 4.1.0-p13 differs from library version 4.2.0.
warning: MPC header version 1.2.1 differs from library version 1.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/include"
ignoring duplicate directory "/usr/local/include"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/x86_64-pc-linux-gnu
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/backward
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include-fixed
 /usr/include
End of search list.
GNU C++17 (GCC) version 12.2.0 (x86_64-pc-linux-gnu)
	compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP

warning: MPFR header version 4.1.0-p13 differs from library version 4.2.0.
warning: MPC header version 1.2.1 differs from library version 1.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 402ce889a414e2a3abbbe3146fa0a6cb
COLLECT_GCC_OPTIONS='-v' '-I' '/usr/local/include' '-L/usr/local/lib' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 as -v -I /usr/local/include --64 -o /tmp/ccnaLg4i.o /tmp/ccm8ymhR.s
GNU assembler version 2.39.0 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.39.0
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-I' '/usr/local/include' '-L/usr/local/lib' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a.'
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/collect2 -plugin /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/cc952HXo.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../lib/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/crtbeginS.o -L/usr/local/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../.. -rpath /usr/local/lib /tmp/ccnaLg4i.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../lib/crtn.o
/usr/bin/ld: /tmp/ccnaLg4i.o: in function `main':
search.cpp:(.text+0x20): undefined reference to `hdt::HDTManager::mapHDT(char const*, hdt::ProgressListener*)'
collect2: error: ld returned 1 exit status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant