Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle library paths with special chars better in Windows #7598

Open
adrpo opened this issue Jun 22, 2021 · 3 comments
Open

Handle library paths with special chars better in Windows #7598

adrpo opened this issue Jun 22, 2021 · 3 comments

Comments

@adrpo
Copy link
Member

adrpo commented Jun 22, 2021

Description

See:
https://www.openmodelica.org/forum/default-topic/3309-tank-system-simulation#p10967

Steps to Reproduce

  • Load a library from a path that include special chars: c:\path\to\åöä\my\LIB\package.mo
  • Compile a model from this library. OMC will add:
    • -L"C:/path/to/åöä/my/LIB/Library/Resources/Library/mingw64"
    • -I"C:/path/to/åöä/my/LIB/Library/Resources/C-Sources"
      which will get you a "file not found" error

Expected Behavior

It should just compile fine.
I guess we should use GetShortPathNameW when we load the library if it has special chars.

Version and OS

  • OpenModelica Version: 1.17+
  • OS: Windows 10, 64 bit
@adrpo
Copy link
Member Author

adrpo commented Mar 23, 2022

From @sjoelund: I suppose we could add a notification or something from omc that it won't handle the library in these cases? Even something as simple as loadModel/loadFile checking for non-ASCII strings would be easy and more helpful than random failures.

From @adrpo:
I guess we should transform all the paths with special chars into short name paths (if possible) as we do with the temp path:
'C:/Users/CGASTE~1/AppData/Local/Temp/OPENMO~1/OMEdit/MODELI~1.GEN'
that would fix all the issues but will look ugly.
Also, maybe it would not work for loading libaries understanding that MODELI~1 is "Modelica 3.2.3+maint.om" gets harder.
I need to make some tries and see if we can fix this somehow without translating to short paths. Maybe the msys environment
gives me that error and not gcc or clang, will try in the cmd directly.

From @sjoelund: Could also just do that for the APPDIR path when resolving that? And use ~1 on that but not on .openmodelica/libraries? Or only on the directories containing non-ASCII symbols?

From @adeas31: AFAIR the compilation works fine with short names but the linker doesn't like them.

@adrpo
Copy link
Member Author

adrpo commented Mar 23, 2022

See also: #8507.

adrpo added a commit to adrpo/OpenModelica that referenced this issue Mar 23, 2022
- change path with special chars to a path with short names for getModelicaPath and getHomeDirectoryPath
- not working yet if you load a file (or library) from a path with special chars (should be easy to fix as well)

For a directory: C:\dev\Åbäröéü you would get:
getHomeDirectoryPath()
"C:/dev/BRC381~1/"
getModelicaPath()
"C:/dev/BRC381~1//.openmodelica/libraries/;c:/home/adrpo33/dev/OpenModelica/build/lib/omlibrary"

With these changes you can properly install and load
libraries via the PackageManager and compile and link
your model.
adrpo added a commit that referenced this issue Mar 24, 2022
- change path with special chars to a path with short names for getModelicaPath and getHomeDirectoryPath
- not working yet if you load a file (or library) from a path with special chars (should be easy to fix as well)

For a directory: C:\dev\Åbäröéü you would get:
getHomeDirectoryPath()
"C:/dev/BRC381~1/"
getModelicaPath()
"C:/dev/BRC381~1//.openmodelica/libraries/;c:/home/adrpo33/dev/OpenModelica/build/lib/omlibrary"

With these changes you can properly install and load
libraries via the PackageManager and compile and link
your model.
@casella
Copy link
Contributor

casella commented Mar 28, 2022

See #8777, that problem is still unsolved. Maybe accented letters and whitespace are even worse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants