Use 'dfwin' Fortran library with gfortran - gcc

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.)

Related

Cannot load lua dll module

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).

How to use MinGW-W64 ld to link with ifort's dll on Windows

I have a library is compiled from Intel Fortran Compilers on Windows
It has two file foo.dll and foo.lib
Because the function name decoration of windows's ifort is different with gfortran or linux's ifort, when I directly link with foo.lib (-lfoo) it will cause undefined reference to 'bar_'.
I use pexports to generate def file and edit like that
LIBRARY foo.dll
EXPORTS
bar_ = bar
...
and use dlltool -d foo.def -l foo.a to make a .a file
I can link to foo.a successfully, but when the program run, it throw
The specified procedure could not be found.
Entry Point Not Found
How can I directly link bar_ function in source object to bar function in dll?
I don't want to write a warp.
P.S.
I also had try to static link to original linux's .a on Mingw-w64 on Windows, the ld show could not read symbols: Invalid operation.

Can gcc build an executable without access to a required shared library?

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

Cygwin-to-Linux cross-compiling gcc fails because it can not find a shared library, but it does not tell me which

I have obtained and installed a Cygwin-to-Linux cross-compiler from the Cygwin Ports Project and am trying to use it to compile a simple "Hello world"-program. Then this happens:
$i686-pc-linux-gnu-gcc main.c
/usr/bin/i686-pc-linux-gnu-g++.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
Obviously, GCC can't find some DLL. Unforntunately, it does not print which and I do not know how I can find out.
This even happens when I try something as simple as running the preprocessor (through i686-pc-linux-gnu-gcc -E) over a C file that does nothing but return 0.
This GCC is version 4.7.2.
Does someone know how I can fix this? Or at least how I could find out the name of the library which can not be found?

gcc undefined _cxa_pure_virtual

I have 2 shared object libs and one executable.
1 of the libs that I compile has linkage error: Undefined _cxa_pure_virtual.
Why?
Usually we do not need to implement it. Any Ideas?
If I implement it both the libs compile and link OK, but the application that links to both has same linkage issue?
The lib in question is a C++ library and the __cxa_pure_virtual is needed by the C++ runtime. Suggest that you try first linking with g++ command instead of gcc.
Read more under this question: What is the purpose of cxa pure virtual

Resources