I am working with a PowerPC processor and have to use dcache functions in my kernel module, like: "clean_dcache_range()", implemented in $KERNEL_SOURCE/arch/powerpc/kernel/misc_32.S. this assembly file is compiled during kernel compilation (version 4.1.8) and misc_32.o object file exists in kernel build directory.
However, i can't use this functions in my kernel module and the error "implicit declaration of function" appears when i compile the module using gcc.
Also, the Module.symvers file does not contain these functions.
Note that, the mentioned functions are declared as _GLOBAL.
So, what is the problem and how can i solve it?
Related
I am building the shared library which can be used for my python program using command.
go build -o program.so -buildmode=c-shared myprogram/program.go
However, it seems that for me to use the shared library on another machine, I have to include all the source code. Otherwise, I would get OSError: invalid ELF header.
Is using the shared library without source code possible?
Library is a binary artifact and will only work on same architecture as it was built for. OSError: invalid ELF header means the library is for different architecture (e.g. library built on x86_64 Linux won't load on arm Linux, x86_64 MacOS X and so on).
Use without source code is perfectly possible if you build library binaries for all architectures (CPU and OS) where your users intend to use it.
I cannot load a lua module, which is a 32bit c++ dll.
The lua module and the lua code is in the same folder.
in c++ code:
extern "C" __declspec(dllexport) int luaopen_luartmidi(lua_State *L) {
...
}
lua first line:
local luartmidi = require 'luartmidi'
When i run the lua code with vs code lua 32bit debugger i get
error message:
Exception has occurred: [C]:-1: error loading module ... from file ...
The specified function could not be found
Dependency Walker says LUA.DLL is missing. When i copy lua.dll in the same folder i get error
c:Users/xyz/.vscode/extensions/actboy168.lua-debug-1.23.1/runtime/win32/lua53/lua.exe: multiple Lua VMs detected
This happens when you link with a lua interpreter statically and then try to load an external module that links against a Lua DLL (and expects a lua.dll or similarly named library to be present). You can't both have a statically compiled interpreter and one loaded from a DLL to be present in the same process (the "multiple Lua VMs detected" message is triggered by a check against this condition).
You have three options:
Compile everything statically (don't load any external modules)
Compile everything dynamically (don't link the Lua interpreter statically)
Use a proxy library that will forward API calls from external libraries to statically linked Lua interpreter (will require exporting Lua symbols and writing a proxy library). See http://lua-users.org/wiki/LuaProxyDllFour links for the code and details (it's for Lua 5.1, but you can tweak the script for Lua 5.3).
I'm compiling a shared library with gcc and loading it using dlopen. I also pass the following to the compiler:
-fvisibility=hidden
When I compile the library WITHOUT the visibility flag, everything works perfectly. However, when I compile WITH the flag, I get the following error with dlopen:
libtest.so: cannot open shared object file: No such file or directory
The linbrary .so file exists! This seems weird to me, since if some symbols are hidden, I would expect dlsym to fail if something cannot be found. However, this already fails when loading the library (aka dlopen).
I also tried adding
__attribute__ ((visibility ("default")))
to the functions I later call (extern "C"), without any success. Does anyone know what I can do about this? Or alternatively, is there any way to debug this to figure out why dlopen fails? I do not want to remove the visibility flag, since his drastically reduces my executable size.
My lib was depended on another lib that could not be found.
You may use ldd to see the list of all dependencies, including missing.
ldd libtest.so
When building an executable, gcc requires the -l flag to list the shared libraries, even though they can be changed freely without recompiling the executable. Does gcc use that flag only to check if all the symbols are ok? Can I build the executable without performing this verification?
You can use dlopen to load the dynamic library at runtime, and dlsym to get the pointer to the function you like to call.
Here is a sample http://pubs.opengroup.org/onlinepubs/009695399/functions/dlsym.html
I try to load dynamically DLL library in fortran, so I need to use loadlibrary and getprocaddress function from dfwin library.
But when I compile this:
program helloworld
use dfwin
end
I just got:
Fatal Error: Can't open module file 'dfwin.mod' for reading at (1): No such file or directory
Can I install or link in any way dfwin module to gfortran GCC compiler ?
No. The mod file generated by a compiler is specific to that compiler (in some cases, specific to a compiler version).
(Even if you had the source for the dfwin module, it uses extensions that are specific to the DEC/Compaq/Intel compiler lineage.)