Hi,

I'm a newbie in this vast world of programming. I've been given some codes in C which are compiled & linked using makefile. I can compile the code using nmake from VS2005. Now i want to build the program in C++ VS2005 IDE.
From a quick google search, there seems to be no automated functions in importing makefile settings to VS IDE.
I tried to include all the necessary dependecies(header and lib files) stated in the makefile to VS but i get a lot of linking errors. I'm not even sure where to start looking to solve the issue. I hope the gurus can help me out.

The makefile including two other related makefile is attached to this post.
[1]makefile.mak
[2]compiler.mak
[3]options.mak

In VS I've:
[1] Create a new empty project
[2] Add exisiting sources (c files and header files)
[3] Additional Include Directories: ..../include and ..../src/make7
[4] Additional Library Directories: ..../lib
[5] Build project...

I got 74 linker errors the VS output after attempted build. Example:

conmain.obj : error LNK2001: unresolved external symbol _MMSd_freeDsMemFunction
scl_cli.obj : error LNK2019: unresolved external symbol _TAM_parse_address referenced in function _ResolveServerAddress

I've not dealt with makefiles before. I apologize if this post may sound very newbie style and amatuer-ish. I'm new but I'm willing to learn.

Any advice and comment is greatly appreciated.

jjplaw

Attachments
# ******************** Microsoft C version ************************
COMPILER    = cl /nologo /D:_MSC_VER=1 @$(BASE)\vc.cfg
LEX         = $(BASE)\exes\flex
MAKE        = nmake/NOLOGO
NAMETAG     = vc
COMPOUT     = /Fo
RESPADD     =
RESPCONT    =
LIBFLAGS    = 
LIBTOOL     = lib
LIBOUT      = /OUT:
LINK        = link /PROFILE /SUBSYSTEM:CONSOLE /debug /INCREMENTAL:NO /NODEFAULTLIB:libc
LINKOUT     = /OUT:
WINDIS      = $(BASE)\lib\ndif_$(NAMETAG).lib
SOCKLIB     = ws2_32.lib user32.lib
REGLIB      = advapi32.lib

OBJSUFFIX   = obj
LIBSUFFIX   = lib
EXESUFFIX   = exe

DELETE      = -del
#DELETE      = delete
RENAME      = rename
COPY        = copy
BASE        = ..\..
!include $(BASE)\compiler.mak
!include $(BASE)\options.mak

CFLAGS      = 

# Define the string used in the executable file name
STACK_DEF   = $(TCP_DEF)

!ifdef TCP_DEF
STACKS      = tcp
!endif

CDEFS       = $(STACK_DEF) $(AUTH_DEF) $(CLIENT_DEF) $(FILESERVICE_DEF)

TARGET      = $(STACKS)$(NAMETAG).$(EXESUFFIX)

GOMDIR      = $(BASE)\src\classlib
DIRMAKE     = $(BASE)\src\make7
LIBDIR      = $(BASE)\lib
OBJDIR      = obj_$(NAMETAG)
EXEDIR      = $(BASE)\exes
USERINC     = $(BASE)\include

# These libraries are always included
TAMLIB      = $(LIBDIR)\tam_$(NAMETAG).lib
TAMCLIB     = $(LIBDIR)\tamc_$(NAMETAG).lib
MMSLIB      = $(LIBDIR)\mmsc_$(NAMETAG).lib

# Optional libraries
!ifdef FILESERVICE_DEF
FILELIB     = $(LIBDIR)\file_$(NAMETAG).lib
!endif

!ifdef TCP_DEF
TCPLIB      = $(LIBDIR)\1006_$(NAMETAG).lib
TCPINC      = $(USERINC)\rfc1006.h
!endif

!ifdef CLIENT_DEF
CLILIB      = $(LIBDIR)\cli_$(NAMETAG).lib
TCLILIB     = $(LIBDIR)\tcli_$(NAMETAG).lib
CLIINC      = $(USERINC)\cliapi.h $(USERINC)\cli_cfg.h
!endif

SCLLIB      = $(LIBDIR)\cscl_$(NAMETAG).lib

LIBS        = $(TCPLIB) $(TCLILIB) $(CLILIB) \
	      $(TAMLIB) $(TAMCLIB) $(MMSLIB) $(FILELIB) $(SCLLIB)

INCLUDES    = $(TCPINC) $(CLIINC)

CC          = $(COMPILER)
INCFLAGS    = /I$(DIRMAKE) /I$(USERINC)

SRC         = conmain.c \
	      state.c \
	      scl_cli.c

OBJ         = $(OBJDIR)\$(STACKS)main.$(OBJSUFFIX) \
	      $(OBJDIR)\state.$(OBJSUFFIX) \
	      $(OBJDIR)\scl_cli.$(OBJSUFFIX)

all:        $(TARGET)

install:    all

clean:
	    $(DELETE) $(OBJDIR)\$(STACKS)main.$(OBJSUFFIX)
	    $(DELETE) $(OBJDIR)\state.$(OBJSUFFIX)
	    $(DELETE) $(OBJDIR)\scl_cli.$(OBJSUFFIX)
	    $(DELETE) $(TARGET)

clobber:    clean

$(TARGET):      $(OBJ) $(LIBS)
	    $(LINK) $(LINKOUT)$(TARGET) @<<
	$(OBJDIR)\$(STACKS)main.$(OBJSUFFIX)
	$(OBJDIR)\state.$(OBJSUFFIX)
	$(OBJDIR)\scl_cli.$(OBJSUFFIX)
	$(LIBS)
	$(WINDIS) $(SOCKLIB) $(REGLIB)
<<NOKEEP

$(OBJDIR)\$(STACKS)main.$(OBJSUFFIX): \
		conmain.c \
		database.h \
		services.h \
		scl_cli.h \
		$(USERINC)\uca_time.h \
		$(DIRMAKE)\tamvend.h \
		$(USERINC)\tam.h \
		$(USERINC)\tam_tp.h \
		$(USERINC)\tam_con.h \
		$(USERINC)\casm.h \
		$(DIRMAKE)\clivend.h \
		$(USERINC)\cliapi.h \
		$(DIRMAKE)\mmsdapi.h $(INCLUDES)
		$(CC) $(INCFLAGS) $(CFLAGS) @<<
		    $(CDEFS)
		    $(COMPOUT)$(OBJDIR)\$(STACKS)main.$(OBJSUFFIX)
		    conmain.c
<<NOKEEP

$(OBJDIR)\scl_cli.$(OBJSUFFIX): \
		scl_cli.c \
		scl_cli.h \
		database.h \
		services.h \
		$(USERINC)\uca_time.h \
		$(DIRMAKE)\tamvend.h \
		$(USERINC)\tam.h \
		$(USERINC)\tam_tp.h \
		$(USERINC)\tam_con.h \
		$(USERINC)\casm.h \
		$(DIRMAKE)\clivend.h \
		$(USERINC)\cliapi.h \
		$(DIRMAKE)\mmsdapi.h $(INCLUDES)
		$(CC) $(INCFLAGS) $(CFLAGS) @<<
		    $(CDEFS)
		    $(COMPOUT)$(OBJDIR)\scl_cli.$(OBJSUFFIX)
		    scl_cli.c
<<NOKEEP

$(OBJDIR)\state.$(OBJSUFFIX): \
		state.c \
		scl_cli.h \
		database.h \
		services.h \
		$(USERINC)\uca_time.h \
		$(DIRMAKE)\tamvend.h \
		$(USERINC)\tam.h \
		$(USERINC)\tam_tp.h \
		$(USERINC)\tam_con.h \
		$(USERINC)\casm.h \
		$(DIRMAKE)\clivend.h \
		$(USERINC)\cliapi.h \
		$(DIRMAKE)\mmsdapi.h $(INCLUDES)
		$(CC) $(INCFLAGS) $(CFLAGS) @<<
		    $(CDEFS)
		    $(COMPOUT)$(OBJDIR)\state.$(OBJSUFFIX)
		    state.c
<<NOKEEP
FILESERVICE_DEF = -DUSE_FILES 
DOWNLOAD_DEF = -DUSE_DLSM 
AUTH_DEF = -DUSE_AUTH 
CLIENT_DEF = -DUSE_CLIENT 
TCP_DEF = -DUSE_TCP 
DAT_DEF = -DUSE_DATA 
RTG_DEF = -DUSE_RTG 
SCL_DEF = -DUSE_SCL 
XML_DEF = -DUSE_XML 
# XMLFS_DEF = -DUSE_XML_FAKE_FS 
CONSOLE_DEF = -DUSE_CONSOLE 
SIM_DEF = -DUSE_SIMULATE 
THREAD_DEF = -DTAM_USE_THREADS

> [4] Additional Library Directories: ..../lib
From your errors (all unresolved errors it seems), the only thing missing are the "additional library names"
On the link tab IIRC.

I've already added the lib folder in the additional libraries tab in VC project properties. The lib folder contains all the lib files stated in the makefile.

[1] Could it be that i'm trying to compile/link pure C codes using a C++ compiler/linker?

[2] The application has 3 .c codes. In the makefile, conmain.c is compiled to produce tcpmain.obj instead of conmain.obj. I assume that this will not effect anything in VS IDE but i just wanna confirm with the experts first. If it does effect, how can i do it in VS IDE?

[3] In the makefile, CDEFS = $(STACK_DEF) $(AUTH_DEF) $(CLIENT_DEF) $(FILESERVICE_DEF)

$(STACK_DEF) = -DUSE_TCP
$(AUTH_DEF) = -DUSE_AUTH
$(CLIENT_DEF) = -DUSE_CLIENT
$(FILESERVICE_DEF) = -DUSE_FILES

What are those parameters and what do they do? Is it specific to this application or common. In the makefile, its used when compiling the 3 .c files to .obj files.

[4] Any idea what is the symbol @<< in the makefile? I cant seem to find the answer from google searching.

Please advise.

justin

This article has been dead for over six months. Start a new discussion instead.