c++ - Multiple definiton of function when including library -
i try include headers library in different files of project , multiple definition errors on functions of library. after reading answer this question think problem functions implemented directly in header files of library.
in particular want include files codecfactory.h
, deltautil.h
fastpfor. don't know if relevant problem include cmake project code in cmakelists.txt:
include_directories(../../fastpfor/headers) add_library(fastpfor static ../../fastpfor/src/bitpacking.cpp ../../fastpfor/src/bitpacking.cpp ../../fastpfor/src/bitpackingaligned.cpp ../../fastpfor/src/bitpackingunaligned.cpp ../../fastpfor/src/horizontalbitpacking.cpp ../../fastpfor/src/simdunalignedbitpacking.cpp ../../fastpfor/src/simdbitpacking.cpp ${headers} )
everything works fine if include files once. use them in 2 .cpp files these kinds of errors:
cmakefiles/dbgen.bin.dir/queries/query5.cpp.o: in function `vsencoding::bitswriter::bitswriter(unsigned int*)': query5.cpp:(.text+0x8420): multiple definition of `vsencoding::bitswriter::bitswriter(unsigned int*)' cmakefiles/dbgen.bin.dir/queries/query13naive.cpp.o:query13naive.cpp:(.text+0x7a50): first defined here
is there way can fix without having change fastpfor code own?
the question linked says - there no way solve without modifying headers (or include them in 1 source file).
for instance this line defines non-inline constructor in header. including in more 1 translation unit result in violation of odr rule.
Comments
Post a Comment