Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Windows omc cannot target C language: "dladdr failed: not available"

Windows omc cannot target C language: "dladdr failed: not available"

I'm attempting to use OMC with the C language target on Windows 7 32-bit with OpenModelica1.11.0-32bit. I've also attempted the same procedure with OpenModelica1.12.0-dev-32bit with the same results. When I run omc -s path/to/MyModel.mo, I get the following error:

Code:


dladdr failed: not available on Windows failed
Error processing file: path/to/MyModel.mo
Error: Failed to write to file (not open)
Error: Template error: A template call failed (a call with 0 parameters: dladdr
failed: not available on Windows). One possible reason could be that a template
imported function call failed (which should not happen for functions called from
within template code; templates preserve pure 'match'/non-failing semantics).

# Error encountered! Exiting...
# Please check the error message and the flags.

I'm not sure why OMC is trying to use dladdr on Windows. There is a bug report that also contains this error, but was two months ago--long before the two releases I'm using were released. Anyone else having an issue targeting C on Windows?

Re: Windows omc cannot target C language: "dladdr failed: not available"

This seems to be an error in 32bit OM. It works fine with the 64bit OM. Do you specifically need the 32bit one?

Re: Windows omc cannot target C language: "dladdr failed: not available"

Yeah--we're only allowed to run 32-bit Windows at my work, so I have to use the 32-bit version of OM. I've done a little tracing:

1) The dladdr call is available on *NIX systems (Linux, OS X) but not Windows. The Windows way of performing the same task is GetModuleFilename(). The LibGW32C for Windows project also provides a compatibility layer.
2) OMCompilter/Compiler/runtime/systemimpl.c provides SystemImpl__dladdr(). On MINGW32, it returns two strings: "dladdr failed" and "not available on Windows".
3) OMCompiler/Compiler/Util/System.mo has _dladdr() which calls the function above. dladdr() calls _dladdr().
4) dladdr() is called many places, but in my case, the call appears to be in OMCompiler/Compiler/SimCode/SimCodeMain.mo:runCodegenFunc(). I think the dladdr() function is called when the return value of the passed in func() is not defined.

So now I have a few questions:
1) Why is the conditional compile in #2 only checking MINGW32? Is dladdr available on MINGW64 but not MINGW32?
3) If dladdr isn't available on some platforms, why do we use it as if it's always available (such as in #4)?

Re: Windows omc cannot target C language: "dladdr failed: not available"

I will do some debugging of my own to fix this. I had no time to look too deep into this as I'm the one fixing Windows issues, but thanks for your investigation.
What I find really strange is that mingw64 works fine but mingw32 does not.

Your questions:
1) MINGW32 is defined in both mingw64 and mingw32
2) In general we try to keep the same Linux based interface and write small Windows layers to implement missing functions, but somehow this one escaped me.

Re: Windows omc cannot target C language: "dladdr failed: not available"

It seems we're having issues generating C code in parallel. I'll need to debug more.

For now, to make it work you can add -n=1 to omc command:

Code:


omc -n=1 -s path/to/MyModel.mo

Re: Windows omc cannot target C language: "dladdr failed: not available"

That work around seems to work fine on 32-bit Windows 7. Thanks!

Re: Windows omc cannot target C language: "dladdr failed: not available"

I also fixed it properly in the nightly builds:
https://build.openmodelica.org/omc/buil … lds/32bit/

There are 0 guests and 0 other users also viewing this topic
You are here: