You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"
The trick is to include only once per "project" the lsh_nn_table_impl.h file, ideally in one of your cpp files (so the definitions lay in only one object file of your project) and then use lsh_nn_table.h where needed across your project.
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.
The text was updated successfully, but these errors were encountered: