Solved How to force the linker to search in /usr/local/lib globally?

  • Thread starter Deleted member 66267
  • Start date
D

Deleted member 66267

Guest
This piece of software I ported from Linux. It expects all of the libraries to be in /usr/lib. It's not written in a programming language I know so I can only modify the make file to make it build. The software generates C source files and build it using a C compiler to get the finally executable. Just grab the generated C sources and build manually is not an option, to be clear. The software allows passing of linker flags to it directly via -Wl, so I have something like that:

alias foo='foo -Wl -L/usr/local/lib'

I wonder if there is any way to force the linker to search in /usr/local/lib globally. This alias above only works when using the shell but not in a make file. The stupid make file actually check for the existent of the 'foo' binary and don't use the value I specified with FOO='foo -Wl -L/usr/local/lib'

p/s: I mean the linker to search this location at compile time, not run time, please don't confuse between them.
 
Compiler is going to need to find header files in /usr/local/include for those libraries in /usr/local/lib. So you're going to need to modify a bunch more. Besides that, on FreeBSD it's often possible to have different versions so you often need to include /usr/local/include/<some lib version> too.
 
Compiler is going to need to find header files in /usr/local/include for those libraries in /usr/local/lib. So you're going to need to modify a bunch more. Besides that, on FreeBSD it's often possible to have different versions so you often need to include /usr/local/include/<some lib version> too.
The software is a transpiler, it compiles a DSL language into C source files and it generates it own linker script, too. This is the problem. It expects everything to be Linux-like.
 
Then you're going to need to patch the software in order for it to generate meaningful source code on FreeBSD.
 
Then you're going to need to patch the software in order for it to generate meaningful source code on FreeBSD.
It's not written in C! It's written in... itself! One need to bootstrap it on Linux first, grab to generated C source files and compile them later on FreeBSD. The generated C source files are not human readable. This is the reason why I desperately wanted to force the linker to look for libraries in /usr/local/lib at compile time globally.
 
Finally if there is no solution then I think I will need to wrap the software with a script. When make file calling 'foo', it will indeed called the wrapper script. But I admit I hate and very bad at shell programming, so I don't know how far I could go.
 
First of all, any compiled executable will be in ELF format and this has rpath which you can also modify, see sysutils/patchelf.

Second, instead of doing such weird things, just build it from source with a prefix of /usr/local.

But as you don't even mention the software you are talking about, this smells a lot of trolling just again.
 
If linking is done via compiler (e.g., GCC, Clang) the following may help:
$ export CPATH=/usr/local/include LIBRARY_PATH=/usr/local/lib
As I said above, it generate linker scripts itself and calling ld directly.
 
From its Makefile, it looks pretty portable, and OF COURSE contains this:
Code:
#   prefix           install/uninstall directory, default: /usr/local

Whatever your problem is, I don't think it's "porting" this software.
 
Whatever your problem is, I don't think it's "porting" this software.
It depends on your definition. No one here could help, so I go with my wrapper script. Don't quote me.
 
Back
Top