luceneplusplus / LucenePlusPlus

Lucene++ is an up to date C++ port of the popular Java Lucene library, a high-performance, full-featured text search engine.
luceneplusplus@googlegroups.com
Other
738 stars 232 forks source link

linking issues after 3.0.7 #165

Closed rosorio closed 3 years ago

rosorio commented 3 years ago

After 3.0.8 and more specifically commit 9fe7860, applications like poedit starts reporting linking issues like

ld: error: undefined symbol: Lucene::StringUtils::toUnicode(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
>>> referenced by transmem.cpp
>>>               tm/transmem.o:(TranslationMemoryImpl::Search(Language const&, Language const&, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&))

any idea about how to fix it ?

alanw commented 3 years ago

@p01arst0rm Can you help me out here?

p01arst0rm commented 3 years ago

@p01arst0rm Can you help me out here?

undefined symbol sounds like a header issue ..

p01arst0rm commented 3 years ago

@p01arst0rm Can you help me out here?

undefined symbol sounds like a header issue ..

wait no i remember this, its an issue with libstemmer, you need to set it to use utf8.

p01arst0rm commented 3 years ago

@p01arst0rm Can you help me out here?

undefined symbol sounds like a header issue ..

wait no i remember this, its an issue with libstemmer, you need to set it to use utf8.

nope, just checked;- its not that. poedit isnt including lucene headers properly, either because they broke something in their code or lucene++ isnt correctly installed on your machine.

@rosorio can you give details about your current setup?

rosorio commented 3 years ago

@rosorio can you give details about your current setup?

Sure, the FreeBSD project has an old version of poedit (1.8.4) who works perfectly until lucene++ was updated from 3.0.7 to 3.0.8. After that even upgrading poedit to 2.4.2 doesn't solve the linking issue.

I try to compile with lucene++ 3.0.7, and it works as expected. So I start trying to build lucene++ from 3.0.7 adding commits (merges essentially) one by one and compiling poedit with this new version. The build breaks after adding commit 9fe7860. My first guess was a change in the class/API visibility due to changes in CMake.

I have to admit I'm not a C++ or CMake expert but, I can try to do some experiments.

Here is the poedit build log with the compiler commands and the errors reported : poedit-1.8.4_33.txt

p01arst0rm commented 3 years ago

@rosorio can you give details about your current setup?

Sure, the FreeBSD project has an old version of poedit (1.8.4) who works perfectly until lucene++ was updated from 3.0.7 to 3.0.8. After that even upgrading poedit to 2.4.2 doesn't solve the linking issue.

I try to compile with lucene++ 3.0.7, and it works as expected. So I start trying to build lucene++ from 3.0.7 adding commits (merges essentially) one by one and compiling poedit with this new version. The build breaks after adding commit 9fe7860. My first guess was a change in the class/API visibility due to changes in CMake.

I have to admit I'm not a C++ or CMake expert but, I can try to do some experiments.

Here is the poedit build log with the compiler commands and the errors reported : poedit-1.8.4_33.txt

that does complicate things somewhat. ill spin up a freebsd vm and have a look.

p01arst0rm commented 3 years ago

@rosorio i wasnt able to replicate this issue, poedit runs just fine on lucene++ 3.0.8.

rosorio commented 3 years ago

@rosorio i wasnt able to replicate this issue, poedit runs just fine on lucene++ 3.0.8.

Good to know, so it's probably something related with compilation options or flags. @p01arst0rm, can you provide more informations about the environment and the compiler you use ?

p01arst0rm commented 3 years ago

@rosorio i wasnt able to replicate this issue, poedit runs just fine on lucene++ 3.0.8.

Good to know, so it's probably something related with compilation options or flags. @p01arst0rm, can you provide more informations about the environment and the compiler you use ?

test@:~ $ clang -v
FreeBSD clang version 10.0.1 (git@github.com:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611aa2)
Target: x86_64-unknown-freebsd12.2
Thread model: posix
InstalledDir: /usr/bin
test@:~ $ ls /usr/local/lib/liblucene++*
/usr/local/lib/liblucene++-contrib.so
/usr/local/lib/liblucene++-contrib.so.0
/usr/local/lib/liblucene++-contrib.so.3.0.8
/usr/local/lib/liblucene++.so
/usr/local/lib/liblucene++.so.0
/usr/local/lib/liblucene++.so.3.0.8
test@:~ $ cmake --version
cmake version 3.19.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).

poedit version 1.8.4.

p01arst0rm commented 3 years ago

i will also add, i discovered that the legacy gcc flag stuff isnt proper in cmake, so i changed it in this pull request. maybe try compiling with this change?

https://github.com/luceneplusplus/LucenePlusPlus/pull/166/files

rosorio commented 3 years ago

Thanks for your help @p01arst0rm . I think I found the cause of the issue

In the liblucene++.pc file generated from liblucene++.pc.in, the @LIB_DESTINATION@ variable is not properly set, leading to a libs parameter like this "-L -llucene++" who confuses the compiler.

p01arst0rm commented 3 years ago

Thanks for your help @p01arst0rm . I think I found the cause of the issue

In the liblucene++.pc file generated from liblucene++.pc.in, the @LIB_DESTINATION@ variable is not properly set, leading to a libs parameter like this "-L -llucene++" who confuses the compiler.

ahhh :)

glad its all fixed !

rosorio commented 3 years ago

Not yet, but I'm working on it

rosorio commented 3 years ago

The .pc file provided by lucene++ package has invalid library path "-L", which causes linkage errors on poedit with FreeBSD. In fact LIB_DESTINATION which contains the library location path is set in cache too early in main CMakeFile, before GNUInstallDirs include. In our case this leads to an empty LIB_DESTINATION variable, and generates the following pc file:

`prefix=/usr/local exec_prefix=${prefix}/bin libdir={libdir} includedir=${prefix}/include/lucene++ lib=lucene++

Name: liblucene++ Description: Lucene++ - a C++ search engine, ported from the popular Apache Lucene Version: 3.0.8 Libs: -L -l${lib} Cflags: -I${includedir} ` My suggestion is to replace %LIB_DESTINATION% with ${libdir}

p01arst0rm commented 3 years ago

The .pc file provided by lucene++ package has invalid library path "-L", which causes linkage errors on poedit with FreeBSD. In fact LIB_DESTINATION which contains the library location path is set in cache too early in main CMakeFile, before GNUInstallDirs include. In our case this leads to an empty LIB_DESTINATION variable, and generates the following pc file:

`prefix=/usr/local exec_prefix=${prefix}/bin libdir={libdir} includedir=${prefix}/include/lucene++ lib=lucene++

Name: liblucene++ Description: Lucene++ - a C++ search engine, ported from the popular Apache Lucene Version: 3.0.8 Libs: -L -l${lib} Cflags: -I${includedir} ` My suggestion is to replace %LIB_DESTINATION% with ${libdir}

ah. I'll take a look, thanks!! its def nothing to do with the c++ or the libraries, i didn't think to check the pc files.

c72578 commented 3 years ago

It looks like this has already been addressed in master: pkgconfig: use correct LIBDIR for destination library https://github.com/luceneplusplus/LucenePlusPlus/commit/39cd44bd54e918d25ee464477992ad0dc234dcba

rosorio commented 3 years ago

excellent, thanks. I think we can close this issue