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

make error #7

Closed
xuzhw opened this issue Mar 10, 2014 · 7 comments
Closed

make error #7

xuzhw opened this issue Mar 10, 2014 · 7 comments
Labels

Comments

@xuzhw
Copy link

xuzhw commented Mar 10, 2014

image

How can I sovle this problem?
CXX=g++ version 4.73
boost version 1.43

@mavam
Copy link
Owner

mavam commented Mar 10, 2014

In the file hash.cc at the very top, could you try including <stdexcept> and see if this helps?

#include <cassert>
#include <stdexcept>   // Bring in exception definitions.

If so, I'll push that fix out.

@xuzhw
Copy link
Author

xuzhw commented Mar 11, 2014

There are some other errors. I tried to solve them by updating my libboost to 1.53, and then make succeed,
But there is an errror when I run a test programme after I installed the libbf.

image

the src code of the test programme is as following:

image

Actually, This is the example programme in the Synopsis.
Maybe I made a mistake in using the libbf?
But how to use this lib exactly?

@mavam
Copy link
Owner

mavam commented Mar 12, 2014

I'm missing a bit of context to assess the problem. Could you tell me what OS and compiler you are using? (The Boost dependency is only necessary for unit testing, 1.53 should suffice). What command line do you use for compiling your code?

Based on the error message, it looks like you forgot to link libbf into your application. Make sure you have -L /path/to/libbf/prefix as part of your compiler options and -lbf after your source, .e.g:

c++ -I /opt/libbf/include -L /opt/libbf/lib test.cc -lbf

To use libbf, you would typically include it the header file bf.h in your application and then start using the provided data structures.

Also, could you confirm that the include fix I proposed solved your initial problem?

@xuzhw
Copy link
Author

xuzhw commented Mar 12, 2014

well, my os version is ubuntu13.10, and the compiler I used here is g++4.73
the command line is as following:g++ testbf.cc -o testbf.out -std=c++11
I have make install before I run the command above.
image
I have trid to add link into the command as your reply.
But there are still some errors here.
image

I checked the path, the lib file is already placed there, there is no problem, well now I am confused.
image

@mavam
Copy link
Owner

mavam commented Mar 12, 2014

It seems the compilation succeeded now. (Note: it's common to put no compiler flags after the linker flags, so I recommend to move the flag -std=c++11 to the beginning, right after g++).

At this point you need to make sure that your library path is set up properly. Because you installed libbf in a non-standard system location, you need to either add /usr/local/lib to your library search path, or what most folks do during testing, just export the environment variable LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=/usr/local/lib
./bftest.out

@xuzhw
Copy link
Author

xuzhw commented Mar 12, 2014

Great!,the test passed. Thanks a lot,Matthias.
Well, I still have a question here, why must I add the link param into the compile command here?
I have include the bf.h and used the bf namespace in the test programme.
When I ref a lib, it is usually the only thing I must do to include the head file into the code.

@mavam
Copy link
Owner

mavam commented Mar 12, 2014

Good to hear it works now!

Because libbf is not a header-only component but also ships with compiled code in the form of library, you need to do both: include the header and link the library to the object code from your own application. By separating the API from the implementation, I have more freedom in terms of the implementation.

In the future, I do plan to make it again a header-only library. It has such a small footprint that this would indeed be a relief from the usability perspective. Since the library does not rely on any other external dependencies, I don't see the need to hide dependencies in the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants