linking against a static library

Posted by ant2009 on Stack Overflow See other posts from Stack Overflow or by ant2009
Published on 2010-12-22T09:44:44Z Indexed on 2010/12/22 9:54 UTC
Read the original article Hit count: 244

Filed under:
|
|

Hello

gcc Version: 4:4.4.4-1ubuntu2
GNU Make 3.81

I have the following library called net_api.a and some header files i.e.

network_set.h

I have include the header file in my source code in my main.c file

#include <network_set.h>

I have the following static library and header in the following directory

./tools/net/lib/net_api.a
./tools/net/inc/network_set.h

In my Makefile I have tried to link using the following, code snippet:

INC_PATH = -I tools/net/inc
LIB_PATH = -L tools/net/lib

LIBS = -lnet_api

$(TARGET): $(OBJECT_FILES)
    $(CC) $(LDFLAGS) $(CFLAGS) $(INC_PATH) $(LIB_PATH) $(LIBS) $(OBJECT_FILES) -o $(TARGET)

main.o: main.c
    $(CC) $(CFLAGS) $(INC_PATH) $(LIB_PATH) -c main.c

However, when I compile I get the following errors:

network_set.h error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘network_String’

Many thanks for any suggestions,

© Stack Overflow or respective owner

Related posts about c

    Related posts about makefile