amplifier
amplifier

Reputation: 1833

Makefile cannot find shared library

I have this folder structure:

Project_folder
Project_folder/Ml.app (folder)
Project_folder/Ml.lib (folder)

In the folder Ml.lib I've created a shared library named ml.so Now I want to link to the client application inside the Ml.app folder. Here's my makefile:

LIBS = -L ../Ml.lib -l ml
INCLUDES = ../Ml.lib
CXXLAGS = -Wall -I$(INCLUDES)
OBJFILES = main.o
TARGET   = mltest
all: $(TARGET)
$(TARGET): $(OBJFILES)
        $(CXX) $(CXXLAGS) -o $(TARGET) $(OBJFILES) $(LIBS) $(LDFLAGS)
        
clean:
        rm -f $(OBJFILES) $(TARGET) *~

but when I try to build it I get

g++ -Wall -I../Ml.lib -o mltest main.o -L ../Ml.lib -l ml /usr/bin/ld: cannot find -lml collect2: error: ld returned 1 exit status make: *** [Makefile:8: mltest] Error 1

Upvotes: 0

Views: 386

Answers (1)

Anonymous1847
Anonymous1847

Reputation: 2588

The option -L specifies an additional search directory for libraries. -l looks for an additonal library. Use:

LIBS = -L .. -l Ml

Upvotes: 1

Related Questions