Thread: rpath issues... I think

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,459

    rpath issues... I think

    I managed to compile my libraries and executable but I'm having issues getting them to link when I try to run the executable, I can see them all in the same folder, I set rapth to '.' on all of them, any ideas why I still get this message despite the makefile below?
    Code:
    ../parser.out: error while loading shared libraries: libparse.so: cannot open shared object file: No such file or directory
    Code:
    DBG:=$(if $(filter 1 true TRUE True,$(DEBUG)),DEBUG=1,)
    name_pfx:=$(if $(DBG),d-)
    name_sfx:=$(if $(DBG),.d)
    obj_sfx:=$(name_sfx).o
    defines:=$(DBG:%=-D %)
    
    ifeq "$(PWD)" ""
    PATH:=..;$(PATH)
    exe_sfx:=.exe
    dll_pfx:=
    dll_sfx:=32.dll
    else
    PATH:=..:$(PATH)
    exe_sfx:=.out
    dll_pfx:=lib
    dll_sfx:=.so
    endif
    
    LIB_PATHS:=..
    LIBRARY_PATH:=$(LIB_PATHS:%=%:)$(LIBRARY_PATH)
    
    $(info *.c=$(wildcard *.c))
    
    src_files:=$(filter-out main.c,$(wildcard *.c))
    obj_files:=$(src_files:%=%$(obj_sfx))
    main_o:=main$(name_sfx)$(obj_sfx)
    inc_files:=$(wildcard *.h)
    
    DFLAGS:=$(if $(DEBUG),-ggdb,)
    LFLAGS:=-Wl,-rpath,.
    SFLAGS:=-shared -fPIC
    BFLAGS:=$(DFLAGS)
    CFLAGS:=$(DFLAGS) $(defines)
    
    exe:=../$(name_pfx)parse$(exe_sfx)
    dll:=../$(dll_pfx)parser$(name_sfx)$(dll_sfx)
    common:=$(dll_pfx)common$(name_sfx)$(dll_sfx)
    
    MAKECMDGOALS?=info
    
    export PATH
    export LIBRARY_PATH
    
    gede: build
    	gede --args
    
    rebuild: clean build
    
    clean:
    	rm -f *.o
    	rm -f $(dll)
    	cd ../common/ && $(MAKE) $(DBG) clean
    
    build: $(exe)
    
    $(exe): $(dll) $(main_o)
    	$(CC) $(BFLAGS) -o $@ $(main_o) $(LFLAGS) -lparse -lcommon
    
    $(dll): $(obj_files)
    	cd ../common/ && $(MAKE) $(DBG) build
    	$(CC) $(SFLAGS) $(BFLAGS) -o $@ $(obj_files) $(LFLAGS) -lcommon
    
    %.c$(obj_sfx): %.c
    	$(CC) $(SFLAGS) $(CFLAGS) -o $@ -c $<
    
    $(main_o): main.c
    	$(CC) $(CFLAGS) -o $@ -c $<
    
    %.c: $(inc_files)

  2. #2
    Registered User
    Join Date
    Apr 2021
    Posts
    75
    Got any output?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,885
    rpath is how make finds things.

    At run-time, you need to study what these tell you.
    ldd(1) - Linux manual page
    ldconfig(8) - Linux manual page
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,459
    Quote Originally Posted by aghast View Post
    Got any output?
    That's literally the 1st "code" block in my post


    Edit: Things worked out after I made this change:
    Code:
    vpath %.exe ../
    vpath %.out ../
    vpath %.dll ../
    vpath %.so ../
    
    gede: build
    	cd ../ && gede --args ./$(exe)
    
    run: build
    	cd ../ && ./$(exe)
    So by the looks of it I had to enter the directory first then launch it, doesn't scream portable to me but better than nothing for now, would appreciate ideas on how to resolve that

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Having a few issues with this...
    By FuzzyMidget in forum C Programming
    Replies: 6
    Last Post: 02-09-2014, 04:07 PM
  2. GCC 4.1.2 Issues
    By padadhic in forum Linux Programming
    Replies: 1
    Last Post: 10-11-2010, 06:17 AM
  3. ASM w/ C++ issues
    By RobotGymnast in forum C++ Programming
    Replies: 17
    Last Post: 09-20-2008, 03:11 AM
  4. issues
    By Logan1033 in forum C Programming
    Replies: 12
    Last Post: 08-16-2006, 01:54 PM
  5. An app to add an rpath?
    By valis in forum Tech Board
    Replies: 1
    Last Post: 07-15-2006, 01:50 AM

Tags for this Thread