Hi
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.
Roman
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",
skel_op_tuples);
}
};
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
%.$(SHLIBEXT): %.$(OBJEXT)
@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
clean:
rm -rf .libs
rm -f core *~ *% *.bak *.o *.$(SHLIBEXT)
distclean: clean
rm config.* Makefile
Hi Roman,> 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. > Roman > > 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", > skel_op_tuples); > } > }; > > > And my Makefile: > CC = gccThis doesn't look good. You need to use g++ to compile C++.> 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 > > %.$(SHLIBEXT): %.$(OBJEXT) > @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 > clean: > rm -rf .libs > rm -f core *~ *% *.bak *.o *.$(SHLIBEXT) > > distclean: clean > rm config.* MakefileLaurent Pinchart
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 Roman>Hi >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. >Roman > >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", >skel_op_tuples); >} >}; > > >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 > >%.$(SHLIBEXT): %.$(OBJEXT) > @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 >clean: > rm -rf .libs > rm -f core *~ *% *.bak *.o *.$(SHLIBEXT) > >distclean: clean > rm config.* Makefile > > >-- Prosim nepouzivejte starou emailovou adresu phaphe@seznam.cz, moje nova adresa je roman.bouchner@gmail.com. Diky. Please do not use my old email address phaphe@seznam.cz, use roman.bouchner@gmail.com instead. Thanks.