[Samba] VFS module and C++

Roman Bouchner phaphe at seznam.cz
Fri Mar 2 11:12:53 GMT 2007

I have found solution, it is necessary to add -lstdc++ to the linker.
Also good idea is to check and increase log level in smb.conf

>I need to write a simple VFS module and I have to use C++ instead of C.
>I took sample files, compiled it and everything does work. However, when
>I compile it as C++, during the runtime I can see errors in the log:
>Can't find a vfs module.
>I am not experienced C or C++ programmer in linux environment, probably
>I do some silly mistake, but I am really stucked now. I am using Samba
>version 3.0.23a. Thanks for any help.
>The fragment of the code looks like this:
>extern "C" {
> #include "includes.h"
># skeleton methods, tuples are there...
>extern "C" {
>NTSTATUS init_module(void)
>        DEBUG(2,("Inicialization does work"));
>        return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "mytest_vfs",
>And my Makefile:
>CC              = gcc
>CFLAGS          = -g -O2
>CPPFLAGS        =
>LDFLAGS         =
>LDSHFLAGS       = -shared
>INSTALLCMD      = /usr/bin/install -c
>SAMBA_SOURCE    = ../../source
>SHLIBEXT        = so
>OBJEXT          = o
>FLAGS           = $(CFLAGS) -Iinclude -I$(SAMBA_SOURCE)/include
>-I$(SAMBA_SOURCE)/popt -I$(SAMBA_SOURCE)/smbwrapper  -I. $(CPPFLAGS)
>-I$(SAMBA_SOURCE) -I/home/roman/ace/ACE_wrappers/TAO/tao -fPIC
>prefix          = /usr/local/samba
>libdir          = ${prefix}/lib
>VFS_LIBDIR      = $(libdir)/vfs
># Auto target
>default: $(patsubst %.cpp,%.$(SHLIBEXT),$(wildcard *.cpp))
># Pattern rules
>        @echo "Linking $@"
>        @$(CC) $(LDSHFLAGS) $(LDFLAGS) -o $@ $<
>%.$(OBJEXT): %.cpp
>        @echo "Compiling $<"
>        @$(CC) $(FLAGS) -c $<
>install: default
>        $(INSTALLCMD) -d $(VFS_LIBDIR)
>        $(INSTALLCMD) -m 755 *.$(SHLIBEXT) $(VFS_LIBDIR)
># Misc targets
>        rm -rf .libs
>        rm -f core *~ *% *.bak *.o *.$(SHLIBEXT)
>distclean: clean
>        rm config.* Makefile

Prosim nepouzivejte starou emailovou adresu phaphe at seznam.cz,
moje nova adresa je roman.bouchner at gmail.com. Diky.

Please do not use my old email address phaphe at seznam.cz, use
roman.bouchner at gmail.com instead. Thanks.

More information about the samba mailing list