View Full Version : LW92 compiling problems (C++ vs C)

06-06-2007, 01:12 PM
Hello all,

My plugin broke after the LW7 to LW8 upgrade. We're currently using LW9.2 and so I want to recompile.

I have the LW9.2 SDK. I am using MS Visual Studio 2005 (v8).

The "server.lib" was successfully created, no problems there.

My plugin is in C++ (.cpp files) - and it compiles just fine.

However, it will not link. I am getting linker error "LNK2001: unresolved external symbol" for "_ServerName", "_Activate" and "_ServerClass".

The linker does link with server.lib (as well as some other libraries).

I assume that _ServerName, _Activate and _ServerClass come from the running Lightwave.exe so they are nowhere to be found...???

How do I tell my plugin.cpp file that those symbols are external?

Any help would be appreciated.

06-07-2007, 11:23 PM
That's probably job for extern "C"..

I have just renamed servdesc.c and others to servdesc.cpp etc. and then adding to each project without static linking..

06-08-2007, 10:16 AM

I made a LW plugins makefile to use with VC++ Express 2005 with C++ compiling enabled for all files:

PROJ_NAM = <your main project file here without .c extension>

PROJ_OBJ = $(PROJ_NAM).obj servmain.obj <...other sources...>

LIB_OBJ = servdesc.obj \
shutdown.obj \
startup.obj \
username.obj \

SYS_LIB = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib \
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib

LSDK_INC = C:\lwsdk\include

CC = icl <i'm using Intel C++ compiler, so you can change this value to cl for Microsoft's>

CL_FLAGS = /Ox /I "$(LSDK_INC)" /D "WIN32" /D "_MSWIN" \

LK_FLAGS = $(PROJ_OBJ) server.lib /link /OUT:"$(PROJ_NAM).p" /INCREMENTAL /DLL /DEF:"serv.def" \

$(CC) $(CL_FLAGS) $<

$(PROJ_NAM).p: $(PROJ_OBJ) server.lib serv.def

server.lib: $(LIB_OBJ)

del *.p *.lib *.obj *.exp

the server source files must be copied to the project directory or you can use server.lib after compiling for the first time in other projects

and i attached the sample source "MandFilter" from the SDK with modifications necessary for safe C++ compiling ... :)

I think you can use C++ style classes mixed with this code also safely

any suggestions on improving the way are more than welcome!

best regards

06-08-2007, 03:06 PM
any suggestions on improving the way are more than welcome!

Well, integrated 64bit compilation would be nice... :hey:

06-08-2007, 11:09 PM

I've named my main plugin file DEdgeSlide.cpp (so it uses C++), and I use all those .c files form LW SDK. At the end of DEdgeSlide.cpp, I put

#ifdef __cplusplus
extern "C" {

char ServerClass[] = LWMESHEDITTOOL_CLASS;
char ServerName[] = "DEdgeSlide";

XCALL_(int) Activate(long version, GlobalFunc *global, LWMeshEditTool *local, void *serverData)
return Main(version, global, local, serverData);

#ifdef __cplusplus

and it perfectly works :)