I tried to configure perl-5.18.2.
In checking C library phase, I got following messages.
Checking for GNU C Library...
You are not using the GNU C Library
I can use /mingw/bin/nm to extract the symbols from your C libraries. This
is a time consuming task which may generate huge output on the disk (up
to 3 megabytes) but that should make the symbols extraction faster. The
alternative is to skip the 'nm' extraction part and to compile a small
test program instead to determine whether each symbol is present. If
you have a fast C compiler and/or if your 'nm' output cannot be parsed,
this may be the best solution.
You probably shouldn't let me use 'nm' if you are using the GNU C Library.
Shall I use /mingw/bin/nm to extract C symbols from the libraries? [y] /mingw/bi
n/x86_64-w64-mingw32-nm.exe
I can't seem to find your C library. I've looked in the following places:
/lib
/usr/lib
None of these seems to contain your C library. I need to get its name...
Where is your C library?
Where is my C library?
I've tried /mingw/bin/nm.exe too.
http://search.cpan.org/dist/perl-5.18.2/README.win32:
The INSTALL file in the perl top-level has much information that is only relevant to people building Perl on Unix-like systems. In particular, you can safely ignore any information that talks about "Configure".
Instead, follow the instructions in the README.win32 file.
Related
I'm looking for a libc implementation in a single C source file.
Previously, I tried decompiling musl's libc.so with Ghidra but the result contained too many errors. Even after manually fixing these errors the result is too far removed from the original source code for my needs.
I found this but I was hoping to find something more complete. For example, including some of the math.h functions and printf.
Then today I found a mention of the VAX/VMS C compiler in a comment on this answer which states:
The VAX/VMS C compiler kept all the C runtime library headers in a single textual library file (similar to a unix archive), and used the string between the < and > as the key to index into the library. –
Adrian McCarthy
Feb 15, 2017 at 23:14
This might fit my needs, if the "textual library file" contains C source code.
So primarily I'm looking for a single-file libc.c implementation. But if someone has a link to this VAX/VMS C compiler archive file, I'd be interested in that too.
Suppose that there is a simple binary that depends on three libraries, libA.so, libB.so, and libC.so. In the usual case, these three dependencies would show up in readelf as needed. However, I am curious about whether it is possible to make a shared library libABC.so that does absolutely nothing but act as an interface to the three actual libraries by "redirecting" the symbols. This way, perhaps one can have multiple versions of libABC.so that in turn point to different versions of the three dependencies, and the binary can "depend" on just libABC.so. Is this possible with ELF?
Another possible use case is the inverse, when the binary already depends on an existing library libABC.so that just so happens to have become split up into three individual libraries.
Beware that I do not necessarily have a practical use or actual use case for this. Whether or not the above example cases are practical, I am merely curious about the possibility.
Re-export Shared Library Symbols from Other Library (OS X / POSIX) has a promising title, but the answers seem either Darwin-specific, or do not quite answer this question.
That kind of works with ELF because of the flat namespace of symbols: if you're depending on one library you usually get access to the symbols of its dependencies at the same time (the exception being when dlopen() is used).
But most link editors (ld) do not do that by default (anymore), because it would let unneeded libraries to be added to the dependencies otherwise. In GNU ld the feature is controlled by the --as-needed flag, and was turned on around 10 years ago by default if I remember correctly.
You should be able to force the behaviour you're looking into with GNU ld by linking (e.g. via the GCC frontend) with gcc yourprogram.c -Wl,--no-as-needed -lABC -Wl,--as-needed. That will force linking to libABC.so whether the program is using one of its exported symbols or not.
I have written extensively on the feature, because it solved many problems for distributions at the time, on my blog if you're looking into what the practicalities of it are.
I was wondering if there is a way to create a '.exe' file from ' .m' file in MATLAB, such that it can be run in machine which does not have MATLAB (like it can be done in C, C++).
I know writing a MATLAB function is one way, but I am not sure if it can run in machine without MATLAB.
Also I would like to hide my code and just create a script which can be run by a user using his own data files.
The Matlab Compiler is the standard way to do this. mcc is the command. The Matlab Runtime is required to run the programs; I'm not sure if it can be directly integrated with the executable or not.
If you have MATLAB Compiler installed, there's a GUI option for compiling. Try entering
deploytool
in the command line. Mathworks does a pretty good job documenting how to use it in this video tutorial: http://www.mathworks.com/products/demos/compiler/deploytool/index.html
Also, if you want to include user input such as choosing a file or directory, look into
uigetfile % or uigetdir if you need every file in a directory
for use in conjunction with
guide
Try:
mcc -m yourfile
Also see help mcc
If your code is more of a data analysis routine (vs. visualization / GUI), try GNU Octave. It's free and many of its functions are compatible with MATLAB. (Not 100% but maybe 99.5%.)
mcc -?
explains that the syntax to make *.exe (Standalone Application) with *.m is:
mcc -m <matlabFile.m>
For example:
mcc -m file.m
will create file.exe in the curent directory.
It used to be possible to compile Matlab to C with older versions of Matlab. Check out other tools that Matlab comes with.
Newest Matlab code can be exported as a Java's jar or a .Net Dll, etc. You can then write an executable against that library - it will be obfuscated by the way. The users will have to install a freely available Matlab Runtime.
Like others mentioned, mcc / mcc.exe is what you want to convert matlab code to C code.
The "StandAlone" method to compile .m file (or files) requires a set of Matlab published library (.dll) files on a target (non-Matlab) platform to allow execution of the compiler generated .exe.
Check MATLAB main site for their compiler products and their limitations.
I developed a non-matlab software for direct compilation of m-files (TMC Compiler). This is an open-source converter of m-files projects to C. The compiler produces the C code that may be linked with provided open-source run-time library to produce a stand-alone application. The library implements a set of build-in functions; the linear-algebra operations use LAPACK code. It is possible to expand the set of the build-in functions by custom implementation as described in the documentation.
I have a project written in C which I wish to convert to Perl. A friend of mine suggested to use LLVM. I compiled my C code to LLVM assembly using Clang. Now I'm trying to convert this intermediate representation into Perl but I can't seem to find any backend for it. Would someone point me in the right direction?
No, there isn't such a backend. At least not directly. Emscripten converts LLVM IR to Javascript, and maybe you can use something else to convert that to Perl.
It's a pretty bad idea for moving a project from one language to another. The code will be completely unreadable and un-maintainable. Either do a honest rewrite or wrap your C as a library with Perl's foreign-function interface tools and use it from Perl.
Converting to Perl is a no go. It hasn't been done because emulating C in Perl would be insanely slow. They have completely different type systems, for starters. However, it's wholly unnecessary to convert the code to Perl to call it from Perl. You can load compiled C code from Perl.
What you'll have to do is tell Perl how to call those C functions. Perl deals with scalars and so on, but C deals with ints and so on. This is done using XS.
perlxstut contains the documentation on how to do all this.
We know this module's function is Dynamically load C libraries into Perl code .
But how's its own c library loaded into Perl in the first place?
I judge it should have its own c library because I don't find the function dl_load_file right inside DynaLoader.pm,so it must be in some c library...
Dynaloader is statically linked to Perl (managed by Configure), so that it is always available. It wouldn't work very well if it had to be available itself to load itself.
The source for Dynloader is at /ext/Dynaloader/ in the Perl distribution, which contains a number of different implementations of dl_load_file for the various architectures on which Perl might run.
So yes, dl_load_file is in a library, but it ends up inside perl when perl gets built.