How to use different static library in ld, depending on version installed in the system ?
I need to link my program with esnacc lib which may exists as:
/usr/lib/x86_64-linux-gnu/libcxxasn1.a
or
/usr/local/lib/libc++asn1.a
Write an m4 macro that tries to find the right version of the library.
Set a variable use that variable to link your program against it.
Related
I'm making a perl6 package which contains some c source files that will be compiled into a dynamic link library. I found that the name of the library, such as libperl.so, will be changed into something like "A858A3D6EC5363B3D3F59B1.so" after "zef install". However, the name is used in python code as a module name(libperl). After the change, it is no longer a valid identifier. So, is it possible to prevent the change? If it is, what should I do?
I am not sure if it's possible to do that. Maybe it is.
Inspired by #raiph's link, however, I decided to create a soft link. Now the package works well.
In meson you specify a cross-compiler in a cross-file like:
[binaries]
c = '/opt/yada-yada/gcc/bin/powerpc-yada-yada-gcc'
This is great if you know exactly where your compiler is going to live. If I want to specify the same compiler for Windows, I need a different cross-file like:
[binaries]
c = 'c:\Program Files (x86)\yada-yada\gcc\bin\powerpc-yada-yada-gcc'
Is there a way of using only a single cross-file for both platforms? I thought find_program might help, but I just get an error about a Malformed value in cross file variable c.
No, the entire point of cross-files is to target a specific platform. Just make a directory to keep cross-files in.
If you put your compilers in your path, you don't need to specify an absolute path.
Then, it will work on both systems.
As far as I understand using bazel I can only produce libtensorflow_cc.so and libtensorflow_framework.so.
I need to produce static libs that are position independent (-fPIC) because I'll link them to a dynamic lib of my own later.
I found this answer which suggest the use of a Makefile included in the project.
I successfully used it to replace the libtensorflow_cc.so but what can I do to replace libtensorflow_framework.so?
Not an actual answer, but too long for a comment.
I managed to do something like what you mention using Bazel on Windows. In particular, I wanted to make a single wrapper DLL with one or two headers (limited in functionality) that I could move around easily. I'll write a summary of the things that I did; it's rather convoluted an customized for our needs, but maybe you find something useful.
I pass --config=monolithic to the bazel build command (besides any other option that you need). That will avoid modularizing the library and thus remove the dependency to a libtensorflow_framework.so (see
tools/bazel.rc).
The goal that I build is not any of the ones in the TensorFlow repository. Instead, I add a very small program that uses my wrapper as a new Bazel target (a C++ file plus my headers headers and a BUILD file). So all of TensorFlow had to be compiled beforehand in order to compile this final dummy program.
When I get that done, I take advantage of the fact that Bazel does already compile every subgoal as a static library. I check a file under the bazel-bin directory generated for my dummy program goal with a name ending .params - there I find the path of all the static libraries that were used to compile it.
I copy all of these intermediate static libraries to somewhere else. Also, I copy a bunch of headers I will need to compile my final wrapper (TensorFlow own's, but also Eigen, Protobuf and Nsync now too). I put all of this in a build area I have prepared before.
I use NMake Makefile to produce my custom DLL, using the static libraries, the copied headers and my own thin wrapper.
And that's about it, I think. I have an ugly Bash script I run on MSYS2 that does everything for me. Usually with every new release I need to tweak one or two things (some option in the configure script, some additional headers I need to copy, etc.), but I do get it to work in the end. It's quite a lot of fiddling though, so I'm not necessarily saying you should use the same approach (but feel free to ask for details about any step if you want).
Using the -2.params files #jdehesa mentioned and bazel verbose output (-s switch), you can even create a link command to eventually statically link these intermediate static libraries. I automated this process for Windows/Linux/macOS and included it to the vcpkg package manager. To use it just run vcpkg install tensorflow:x64-windows-static. If you're interested in the sources, you'll find them here.
Is there a way to find out what framework / static libraries have been linked with an iOS build (ipa file) assuming you have no access to the source code?
AFAIK no, because symbols from static libraries are copied into your binary without any reference to the original static library. Maybe there's some magic, but I'm not aware of it.
But you can use nm for example to list symbols in your executable and then guess from where they came from.
I built few open source binary/libraries and found that the binary/library is dependent on other libraries statically.I want it to link dynamically. This would allow my binaries be moved to any location and will be path independent. I mean if i export the Library path the binary should be able to locate the library and run successfully.
Write an interface header file containing signature declarations of all functions from required dependent libraries. Include it in your code.
Depending on requirement, use a platform specific loadlibrary function to load it, and then use getprocaddress like function to get the address of required function.
Use those addresses to invoke that function thereafter from your code
While compiling and linking make sure you dont statically link those dependent libraries.