Skip to content

The header-only library seems broken #115

@1flei

Description

@1flei

When I try to include "falconn/lsh_nn_table.h" from multiple cpp files, it will cause "multiple definition of ***" linking error for a lot of fht functions, whereas "normal" header-only library should not have this problem (e.g. Eigen).

A minimum example that triggers this problem may be like:
a.cpp
#include "falconn/lsh_nn_table.h"

b.cpp
#include "falconn/lsh_nn_table.h"

main.cpp
#include
int main()
{
std::cout << "hello world" << std::endl;
return 0;
}

CMakeLists.txt
PROJECT(TEST_FALCONN)

set (CMAKE_CXX_STANDARD 17)

include_directories("FALCONN/src/include")
include_directories("FALCONN/external/simple-serializer")
include_directories("FALCONN/external/eigen")

ADD_EXECUTABLE(test ${DIR_SRCS}
"a.cpp"
"b.cpp"
"main.cpp"
)

and when linking a.o and b.o together, it will report multiple definition of *** (e.g. helper_float_/helper_double_/...).

I tried cmake 3.12.0 and gcc/g++6.5/8.0 although I do not think it is the problem of the version of compiler/toolchain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions