evaleev / libint

Libint: high-performance library for computing Gaussian integrals in quantum mechanics
Other
226 stars 95 forks source link

undefined reference to `libint2_*` #130

Closed uovie closed 5 years ago

uovie commented 5 years ago

Dear libint developers:

I meet a problem when compiling "tests/hartree-fock/hartree-fock.cc". When running make check1, it returns ...make: Nothing to be done for 'check1'.. So, I write a new Makefile

CC      := g++
INCL    := /usr/local/libint/2.5.0/include
LIBS    := /usr/local/libint/2.5.0/lib

TARGETS := HF
OBJ     := hartree-fock.o
DEPS    := 

.PHONY: all clean

all: $(TARGETS)

clean:
    rm -f $(OBJ)

$(OBJ): %.o : %.cc $(DEPS)
    $(CC) -I $(INCL) -L $(LIBS) -c $< -o $@

$(TARGETS): $(OBJ)
    $(CC) $^ -o $@

to carry out the compile procedure. However, it fails with errors in the linking step:

g++ hartree-fock.o -o HF
/usr/bin/ld: hartree-fock.o: in function `libint2::detail::__initializer::__initializer()':
hartree-fock.cc:(.text._ZN7libint26detail13__initializerC2Ev[_ZN7libint26detail13__initializerC5Ev]+0xd): undefined reference to `libint2_static_init'
/usr/bin/ld: hartree-fock.o: in function `libint2::detail::__initializer::~__initializer()':
hartree-fock.cc:(.text._ZN7libint26detail13__initializerD2Ev[_ZN7libint26detail13__initializerD5Ev]+0xd): undefined reference to `libint2_static_cleanup'
/usr/bin/ld: hartree-fock.o: in function `libint2::Engine::finalize()':
hartree-fock.cc:(.text._ZN7libint26Engine8finalizeEv[_ZN7libint26Engine8finalizeEv]+0x3f): undefined reference to `libint2_cleanup_default'
/usr/bin/ld: hartree-fock.o: in function `libint2::Engine::_initialize()':
hartree-fock.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x11a): undefined reference to `libint2_cleanup_default'
/usr/bin/ld: hartree-fock.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x12e): undefined reference to `libint2_need_memory_overlap'
/usr/bin/ld: hartree-fock.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x173): undefined reference to `libint2_init_overlap'
/usr/bin/ld: hartree-fock.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x178): undefined reference to `libint2_build_overlap'
/usr/bin/ld: hartree-fock.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x2ab): undefined reference to `libint2_cleanup_default'
... ...

I do not know how to solve it and correctly compile it. Looking forward to your reply.

Sincerely, Haoyu Lin

uovie commented 5 years ago

It has been solved with the Makefile

CC      := g++
INCL1   := /usr/local/libint/2.5.0/include
INCL2   := /usr/local/libint/2.5.0/include/libint2
LIBS    := /usr/local/libint/2.5.0/lib

TARGETS := HF
OBJ     := hartree-fock.o
DEPS    := 

.PHONY: all clean

all: $(TARGETS)

clean:
    rm -f $(OBJ)

$(OBJ): %.o : %.cc $(DEPS)
    $(CC) -c $< -o $@ -I $(INCL1) -I $(INCL2) -lint2 -L $(LIBS)

$(TARGETS): $(OBJ)
    $(CC)  $^ -o $@ -I $(INCL1) -I $(INCL2) -lint2 -L $(LIBS)

Thanks!