DCPROGS / HJCFIT

Full maximum likelihood fitting of a mechanism directly to the entire sequence of open and shut times, with exact missed events correction.
GNU General Public License v3.0
9 stars 4 forks source link

Compile error on provided example (C++, Linux) #171

Open blairdrummond opened 5 years ago

blairdrummond commented 5 years ago

When I compile a C++ example from DCProgs 0.9 documentation: The Q-Matrix I get a compilation error:

/usr/bin/ld: /tmp/ccStYpLs.o: in function `main':
hjcfit_compile_error.cpp:(.text+0x3d6): undefined reference to `DCProgs::operator<<(std::ostream&, DCProgs::QMatrix const&)'
collect2: error: ld returned 1 exit status

I think the referenced line lives at the bottom of qmatrix.h. And here is the verbose error log.

The error is spawned in the C++ code by the line std::cout << qmatrix << std::endl; and it goes away when run with std::cout << qmatrix.matrix << std::endl;

I am running this on linux (Ubuntu 19.04) with Eigen3.2 installed, and compiling with

g++ -I/usr/local/include/dcprogs/ -I/usr/local/include/eigen3 hjcfit_compile_error.cpp -o hjcfit_compile_error

for convenience, the C++ file is here: hjcfit_compile_error.txt.

I am just getting started with HJCFIT, so I'm wondering how many errors like this I should expect. Is this a portability issue (with Linux v.s. Windows?) and is there any documentation about common problems? Has HJCFIT been tested on linux and macos?

(I am new to C++, so please forgive my possible ignorance if I am missing something obvious.)

remislp commented 5 years ago

I'm not sure why are you getting this error. Which branch are you compiling? Do you get same problem if you compile 'develop' branch?

remislp commented 5 years ago

Have you looked at this: https://github.com/DCPROGS/HJCFIT/wiki/Compiling ?

blairdrummond commented 5 years ago

Sorry for the delay. I compiled on master, but I just repeated this on the develop branch with the same result. Do your machines not replicate this?

I did take a look at the compiling link --- my dependencies should meet or exceed the required versions, but the error also doesn't occur when I compile HJCFIT, but rather when I try to link against it when compiling a program that uses it.

blairdrummond commented 5 years ago

I have figured out what the issue was, I was including the header files, but not the library itself! Which led to an error where all variables were accessible, but functions were not. The solution was to compile with

clang++ -lgmp -lmpfr -llikelihood -I/usr/local/include/dcprogs/ -I/usr/local/include/eigen3 hjcfit_compile_error.cpp -o compile_error

Note the added -llikelihood and g++ -> clang (it does not compile with g++. I don't know why).

This might be worth noting in the documentation or wiki somewhere (so I'll leave this issue open), but I'll let you guys decide on that. Feel free to close this issue.