0

my first post, i have two make files, one building a static library, other is to build with lib linking when i use make for 2nd file i am getting linker error

/usr/bin/ld: skipping incompatible ../development/lib/libstat_cpp.a when searching for -lgurux_dlms_cpp /usr/bin/ld: cannot find -lstat_cpp collect2: error: ld returned 1 exit status makefile:27: recipe for target 'bin/client.bin' failed make: *** [bin/client.bin] Error 1

 anything i am missing? successful on ubuntu 15.04 on x86 intel.

make file1:

Generate STATIC library.

TARGET = libstat_cpp.a
CC = g++
compiling flags here
CFLAGS = -O3 -Wall -fPIC

CFLAGS = -O3 -Wall -fPIC

LINKER = ar rvs
linking flags here

LFLAGS =
change these to set the proper directories where each files shoould be

SRCDIR = src
OBJDIR = obj
LIBDIR = lib

SOURCES := $(wildcard $(SRCDIR)/*.cpp)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
rm = rm -f

$(LIBDIR)/$(TARGET): $(OBJECTS) @$(LINKER) $@ $(LFLAGS) $(OBJECTS) @echo "Linking complete!"

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp @$(CC) $(CFLAGS) -c $< -o $@ @echo "Compiled "$<" successfully!"

.PHONEY: clean clean: @$(rm) $(OBJECTS) @echo "Cleanup complete!" @echo $(OBJECTS)

.PHONEY: remove remove: clean @$(rm) $(LIBDIR)/$(TARGET) @echo "Executable removed!"

make file 2:

project name (generate executable with this name)

TARGET = client.bin

CC = g++
compiling flags here

CFLAGS = -c

LINKER = g++ -o
linking flags here

LFLAGS = -L../development/lib
change these to set the proper directories where each files shoould be

SRCDIR = src
OBJDIR = obj
BINDIR = bin

SOURCES := $(wildcard $(SRCDIR)/*.cpp)
INCLUDES := $(wildcard $(SRCDIR)/*.h)

OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
rm = rm -f

$(BINDIR)/$(TARGET): $(OBJECTS)
@$(LINKER) $@ $(LFLAGS) $(OBJECTS) -lstat_cpp
@echo "Linking complete!"

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
@$(CC) $(CFLAGS) -c $< -o $@
@echo "Compiled "$<" successfully!"

.PHONEY: clean
clean:
@$(rm) $(OBJECTS)
@echo "Cleanup complete!"
@echo $(OBJECTS)

.PHONEY: remove
remove: clean
@$(rm) $(BINDIR)/$(TARGET)
@echo "Executable removed!"
0

solved by re building both make files, sorry

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.