VowpalWabbit / vowpal_wabbit

Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive learning.
https://vowpalwabbit.org
Other
8.49k stars 1.93k forks source link

creating a VW shared library (libvw.so and liballreduce.so) #748

Closed selimrbd closed 9 years ago

selimrbd commented 9 years ago

I am trying to create shared libraries for vowpal wabbit, as I am building a program that needs to link dynamically to VW.

Here is my attempt on the Makefile (for the latest version of VW):

liballreduce.so: allreduce.o
        gcc -shared -fPIC -o $@ $<

libvw.so: $(filter-out vw.o,$(vw_OBJECTS))
        gcc -shared -fPIC -o $@ $+ 

This gets build, but yields error when linked to my C++ code. A typical one:

symbol lookup error: ./exec: undefined symbol: _ZN2VW9get_labelEP7example

What am I doing wrong ?

sharatsc commented 9 years ago

Can you try $(CXX) instead of hardcoding gcc in there? Name munging is complier(and version) specific.

arielf commented 9 years ago

Thanks Sharat,

@slymore If it helps: there's tool called c++filt which demangles symbols:

$ c++filt  _ZN2VW9get_labelEP7example
VW::get_label(example*)

Undefined symbol is commonly caused by one of two things: 1) As Sharat explained: the library and your program were compiled by two different/incompatible compilers do the mangling isn't compatible 2) Dynamic linking isn't finding the library (library is in non standard location OR missing -L during link time)

JohnLangford commented 9 years ago

Is this solved?

Incidentally, I believe the autoconf build creates a shared library.

-John

On 08/17/2015 07:59 PM, Ariel Faigon wrote:

Thanks Sharat,

@slymore https://github.com/slymore If it helps: there's tool called |c++filt| which demangles symbols:

$ c++filt _ZN2VW9get_labelEP7example VW::get_label(example*)

Undefined symbol is commonly caused by one of two things: 1) As Sharat explained: the library and your program were compiled by two different/incompatible compilers do the mangling isn't compatible 2) Dynamic linking isn't finding the library (library is in non standard location OR missing -L during link time)

— Reply to this email directly or view it on GitHub https://github.com/JohnLangford/vowpal_wabbit/issues/748#issuecomment-131998562.

JohnLangford commented 9 years ago

Closing for lack of response.