LIBPATHS is not used in the Makefile, cannot find a shared object

I am having trouble getting the correct link to a sample program (in this case, against the ICU library). When I do, everything builds perfectly. But when I run it, it says that it cannot find one of .so. I double checked that they are all installed in / usr / local / lib. I found that he was browsing / usr / lib. If I symbolically link the actual location from there, it works.

Why are my LIBPATHS ignored or not used?

Here is the makefile

CC = g++

INCPATHS = -I/usr/local/include

CFLAGS = -c -Wall $(INCPATHS)

LIBPATHS = -L/usr/local/lib/
LIBS = $(LIBPATHS) -licuio -licui18n -licuuc -licuio -licudata

EXECUTABLE = prog

print_linking = echo -e "\033[32m" "Linking: $<" "\033[39m"
print_compiling = echo -e "\033[33m" "Compiling: $<" "\033[39m"
print_cleaning = echo -e "\033[31m" "Cleaning: `pwd`" "\033[39m"


all: main

# [target]: [dependencies]
# <tab> system command
main: main.o
    @$(print_linking)
    @$(CC) -o $(EXECUTABLE) main.o $(LIBS) >> /dev/null

main.o: main.cpp
    @$(print_compiling)
    @$(CC) $(CFLAGS) main.cpp 

clean:
    @$(print_cleaning)
    @rm -rf *.o *~ $(EXECUTABLE)
+3
source share
3 answers

LIBPATHS , .

, . , . LD_LIBRARY_PATH, , /etc/ld.so.conf .

+2

. :

  • LD_LIBRARY_PATH ,

  • -Wl, -Rpath

+2

/usr/local/lib LD_LIBRARY_PATH. .profile .cshrc

.

Both solutions have different trade-offs regarding the use of execultable by different users and / or on different machines.

+1
source

Source: https://habr.com/ru/post/1736517/


All Articles