user2309820
user2309820

Reputation: 13

"commands commence before first target" error in a makefile

I read many questions which are similar to this one, but I could not find any good answers.

CC=gcc
CFLAGS= -D__XMLSEC_FUNCTION__=__FUNCTION__ -DXMLSEC_NO_XSLT=1 -DXMLSEC_NO_XKMS=1 -I/usr/include/libxml2 -DXMLSEC_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO=\"openssl\" -DUNIX_SOCKETS -DXML_SECURITY -DDEBUG
LDFLAGS= -lcrypto -I/usr/include/libxml2 -lxml2 -I/usr/local/include/xmlsec1 -lxmlsec1 -lprotobuf-c

$(CC) $(CFLAGS) $(LDFLAGS) src/main.c src/file1.c src/file3.pb-c.c -o   fileClient

This one is my make files. All three header files are in the src directory. The .c files are also in the src directory.

Dependencies Libraries:

Upvotes: 1

Views: 2890

Answers (1)

Alex
Alex

Reputation: 10136

You don't have a target in the Makefile. The make supposes the following general structure:

target: depencies
    commands

Try the following:

CC=gcc
CFLAGS= -D__XMLSEC_FUNCTION__=__FUNCTION__ -DXMLSEC_NO_XSLT=1 -DXMLSEC_NO_XKMS=1 -I/usr/include/libxml2 -DXMLSEC_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO=\"openssl\" -DUNIX_SOCKETS -DXML_SECURITY -DDEBUG
LDFLAGS= -lcrypto -I/usr/include/libxml2 -lxml2 -I/usr/local/include/xmlsec1 -lxmlsec1 -lprotobuf-c


fileClient:
    $(CC) $(CFLAGS) $(LDFLAGS) src/main.c src/file1.c src/file3.pb-c.c -o   fileClient

Upvotes: 1

Related Questions