DataFrame: Undefined reference to `hmdf::HeteroVector::clear()'

When I tried to smoke test my code, I found that even trying to declare a dataframe resulted in an error at compile time. Am I missing a header file?

I’m running Debian 10 and am not using an IDE - I’m simply using g++ (I will create a Makefile once my code makes it past the smoke test). Below is the command I am using and the corresponding error.

username@system:/tmp/smoke_test$ g++ test_dataframe.cpp -I DataFrame/include/ -std=gnu++17 -o test_dataframe /usr/bin/ld: /tmp/ccjU2Oy0.o: in function hmdf::HeteroVector::~HeteroVector()': test_dataframe.cpp:(.text._ZN4hmdf12HeteroVectorD2Ev[_ZN4hmdf12HeteroVectorD5Ev]+0x14): undefined reference to hmdf::HeteroVector::clear()’ collect2: error: ld returned 1 exit status

test_dataframe.cpp.txt

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

Your understanding of the compile process is incorrect. Also, your understanding of what role header files play is incorrect. I still suggest you put some time aside to read up on them.

I still see problems:

  1. The location of DataFrame library is specified as /usr/local/include/DataFrame/. I highly doubt that is where the library is. And if it is there somehow, it shouldn’t be.
  2. You are still specifying and linking with the library when compiling object files.

This is a typical line for compiling an object file

/usr/bin/g++ -g -I. -I../../include -DP_THREADS -D_POSIX_PTHREAD_SEMANTICS -std=c++17 -c ../test/dataframe_tester.cc -o ../obj/Linux.GCC64D/dataframe_tester.o

And this is a typical line to link an executable

/usr/bin/g++ -o ../bin/Linux.GCC64D/dataframe_tester ../obj/Linux.GCC64D/dataframe_tester.o  -Bstatic -L../lib/Linux.GCC64D -lDataFrame -lpthread -ldl -lm -lstdc++

It works! Thank you!

There is nothing wrong with your #include. You are not failing at compiling your program. You are failing at linking your program. That means you are failing to link to DataFrame library to resolve all the external symbols. Now that you have successfully made the DataFrame you have to link with its library on your compiling command line. So change your command line to something like

g++ test_dataframe.cpp -I DataFrame/include/ -std=gnu++17 -Bstatic  -L<Path to where DataFrame Library is> -lDataFrame -lpthread -ldl -lm -lstdc++ -o test_dataframe

That is a typical command line to compile and link any C++ program using a library, whether it is a very simple program or very complicated.

Hope that helps