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

FMU import fails when documents path contains comma #2163

Open
christiansandberg opened this issue Jan 18, 2023 · 3 comments
Open

FMU import fails when documents path contains comma #2163

christiansandberg opened this issue Jan 18, 2023 · 3 comments
Assignees
Labels
bug import/export:fmi FMI import/export or functionality

Comments

@christiansandberg
Copy link

christiansandberg commented Jan 18, 2023

Describe the bug
When importing an FMU and the Hopsan document path contains a comma, the linking stage fails.

To Reproduce

  1. Make sure the Hopsan directory contains a comma
  2. Import an FMU

Expected behavior
Import should be successful.

Screenshots, Model or Data files

Loaded hopsangenerator
Writing compilation script...


Calling compiler utility:
Work Directory: C:/Users/fasx1039/OneDrive - Xylem, Inc/Documents/Hopsan/import/FMU/BouncingBall
Output file:    BouncingBall.dll
Source files:   BouncingBall.cpp
Compiler flags: -I"C:/Program Files/Hopsan/HopsanCore/include" -fPIC -w -Wl,--rpath,"C:/Users/fasx1039/OneDrive - Xylem, Inc/Documents/Hopsan/import/FMU/BouncingBall" -DHOPSAN_BUILD_TYPE_RELEASE -DHOPSANCORE_DLLIMPORT -I"C:/Program Files/Hopsan/dependencies/fmilibrary/include" -I"C:/Program Files/Hopsan/bin/..//dependencies/fmilibrary/include"
Linker flags:   -L"C:/Program Files/Hopsan/bin" -L"C:/Program Files/Hopsan/lib" -lhopsancore -L"C:/Program Files/Hopsan/dependencies/fmilibrary/lib"  -llibfmilib_shared -L"C:/Program Files/Hopsan/bin/..//dependencies/fmilibrary/lib" -llibfmilib_shared -shared


Compiling please wait!

C:\Users\fasx1039\OneDrive - Xylem, Inc\Documents\Hopsan\import\FMU\BouncingBall>if exist BouncingBall.dll (del BouncingBall.dll ) 

C:\Users\fasx1039\OneDrive - Xylem, Inc\Documents\Hopsan\import\FMU\BouncingBall>g++ -I"C:/Program Files/Hopsan/HopsanCore/include" -fPIC -w -Wl,--rpath,"C:/Users/fasx1039/OneDrive - Xylem, Inc/Documents/Hopsan/import/FMU/BouncingBall" -DHOPSAN_BUILD_TYPE_RELEASE -DHOPSANCORE_DLLIMPORT -I"C:/Program Files/Hopsan/dependencies/fmilibrary/include" -I"C:/Program Files/Hopsan/bin/..//dependencies/fmilibrary/include" BouncingBall.cpp -L"C:/Program Files/Hopsan/bin" -L"C:/Program Files/Hopsan/lib" -lhopsancore -L"C:/Program Files/Hopsan/dependencies/fmilibrary/lib"  -llibfmilib_shared -L"C:/Program Files/Hopsan/bin/..//dependencies/fmilibrary/lib" -llibfmilib_shared -shared -o BouncingBall.dll 

C:/Program Files/Hopsan/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.4.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find  Inc/Documents/Hopsan/import/FMU/BouncingBall: No such file or directory
collect2.exe: error: ld returned 1 exit status

Compilation failed.

Hopsan version (please complete the following information):

  • OS: Windows 10
  • Version: HopsanCore 64-bit, Version: 2.20.0.20220711.1354
    HopsanGUI 64-bit, Version: 2.20.0.20220711.1354
  • Build: Official

Additional information
Unfortunately the comma is part of the company name in the OneDrive location where Documents folder is. Changing the location of the Documents folder is not really feasible at scale.

One possible solution could be to use -Xlinker to specify rpath. See for example rust-lang/rust#38798.

ch.addCompilerFlag(QString(R"(-Wl,--rpath,"%1")").arg(libRootDir), Compiler::GCC);

@robbr48
Copy link
Contributor

robbr48 commented Jan 23, 2023

This is a limitation of GCC which cannot be resolved by us. Paths cannot contain commas, cannot be network drives and cannot be longer than 260 characters. There is however a possible workaround:

  1. Open the command prompt ("Start -> cmd")
  2. Run "mklink /J "C:\OneDrive" "C:\Users\fasx1039/OneDrive - Xylem, Inc"
  3. Load the file from C:\OneDrive\Documents/Hopsan/import/FMU/BouncingBall

This will create a link between your actual OneDrive folder and the temporary folder at C:\OneDrive, without moving the files. Please let me know if this works, as I cannot reproduce the problem myself.

@christiansandberg
Copy link
Author

Thanks for the reply! I don't think that will help, because Hopsan will ask Qt where the Documents folder is and store all imported FMUs there including generated C++ files.

Wouldn't it be possible to do something like: -Wl,--rpath -Xlinker "path/to/dir/with , in it". -Xlinker should pass the argument as-is.

@robbr48 robbr48 added bug import/export:fmi FMI import/export or functionality and removed wontfix labels Feb 3, 2023
@robbr48
Copy link
Contributor

robbr48 commented Feb 3, 2023

That could be possible. I will have a look at it. We are in the process of rewriting the entire FMI import feature anyway, but this fix should be a low-hanging fruit.

@robbr48 robbr48 self-assigned this Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug import/export:fmi FMI import/export or functionality
Projects
None yet
Development

No branches or pull requests

2 participants