0
votes

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

1
-L is for directories, -l is for libraries. Use -L .. . - Anonymous1847
@Anonymous1847 I know it but could you tell me how I should change my script? - amplifier
-l ml is wrong, should not have a space in there. - n. 1.8e9-where's-my-share m.
@n.'pronouns'm. doesn't work anyway - amplifier
Also -lml looks for a file named libml.so and not ml.so. - n. 1.8e9-where's-my-share m.

1 Answers

1
votes

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

LIBS = -L .. -l Ml