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

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

Open
blairdrummond opened this issue Jul 16, 2019 · 4 comments
Open

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

blairdrummond opened this issue Jul 16, 2019 · 4 comments

Comments

@blairdrummond
Copy link

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
Copy link
Member

remislp commented Jul 17, 2019

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
Copy link
Member

remislp commented Jul 17, 2019

@blairdrummond
Copy link
Author

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
Copy link
Author

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.

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

2 participants