Opened 11 years ago

Closed 11 years ago

#2680 closed defect (fixed)

Mac OMEdit won't open

Reported by: Adam Dershowitz <dersh@…> Owned by: Martin Sjölund
Priority: high Milestone: 1.9.1
Component: OMEdit Version: trunk
Keywords: Cc:

Description

OMEdit for the Mac will no longer open.

It reports this error:

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  Library not loaded: @rpath/libqjson.dylib
  Referenced from: /Applications/MacPorts/OMEdit.app/Contents/MacOS/OMEdit
  Reason: image not found

Perhaps the problem is that this fix only copies the Windows library and not the Mac library: https://trac.openmodelica.org/OpenModelica/changeset/20316?

Change History (19)

comment:1 by Adam Dershowitz <dersh@…>, 11 years ago

As another data point, version 20221 works fine, but 20315 and 20324 both crash on startup.

comment:2 by Martin Sjölund, 11 years ago

Owner: changed from Adeel Asghar to Martin Sjölund
Status: newaccepted

Nah, the problem is we link against relative paths. And on OSX, OMEdit does not reside in /opt/openmodelica. It's inside the Applications directory in an app somewhere...

Please check if r20331 fixes your problems.

comment:3 by Adam Dershowitz <dersh@…>, 11 years ago

Nope. I just upgraded to r20332 and get the identical error.

comment:4 by Adam Dershowitz <dersh@…>, 11 years ago

otool, which shows the paths used shows this:

 otool -L /Applications/MacPorts/OMEdit.app/Contents/MacOS/OMEdit 
/Applications/MacPorts/OMEdit.app/Contents/MacOS/OMEdit:
	/opt/local/lib/libomniORB4.1.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/libomnithread.3.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
	/opt/local/lib/libqwt.5.dylib (compatibility version 5.2.0, current version 5.2.3)
	@rpath/libqjson.dylib (compatibility version 0.0.0, current version 0.8.1)
	/opt/local/Library/Frameworks/QtWebKit.framework/Versions/4/QtWebKit (compatibility version 4.9.0, current version 4.9.4)
	/opt/local/Library/Frameworks/QtSvg.framework/Versions/4/QtSvg (compatibility version 4.8.0, current version 4.8.5)
	/opt/local/Library/Frameworks/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.5)
	/opt/local/Library/Frameworks/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.5)
	/opt/local/Library/Frameworks/QtXml.framework/Versions/4/QtXml (compatibility version 4.8.0, current version 4.8.5)
	/opt/local/Library/Frameworks/QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.8.0, current version 4.8.5)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)


As a work around I tried this:

install_name_tool -change @rpath/libqjson.dylib /opt/local/lib/omc/libqjson.dylib /Applications/MacPorts/OMEdit.app/Contents/MacOS/OMEdit

And now OMEdit does open. But, if I run a simulation, it crashes with another library that it can't find:

/private/var/folders/s4/0j3cshj161126ygbpbzsdkmd4h24dl/T/OpenModelica_adershowitz/OMEdit/Modelica.Blocks.Examples.PID_Controller -port=51145 -logFormat=xml -w -lv=LOG_STATS
dyld: _dyld_bind_fully_image_containing_address() error
dyld: Symbol not found: _omc_mmap_close_write_unix
  Referenced from: /opt/local/lib/omc/libSimulationRuntimeC.dylib
  Expected in: flat namespace
 in /opt/local/lib/omc/libSimulationRuntimeC.dylib
Process crashed
Simulation process exited with code 0

comment:5 by Martin Sjölund, 11 years ago

If you didn't modify the rpath and launch it from /opt/openmodelica/Applications, would it start ok then?

comment:6 by Adam Dershowitz <dersh@…>, 11 years ago

That folder doesn't exist, so I'm not sure what you have in mind. /opt only contain /X11 /intel and /local. Macports installs most things in /opt/local
OMEdit is installed in /Applications/MacPorts/ and that is the only place that I can find it.

comment:7 by Adam Dershowitz <dersh@…>, 11 years ago

I'm not sure if this is what you had in mind. But, I did try changing to where libqjson.dylib is located and running from there, at the command line, with no changes:

cd /opt/local/lib/omc
open /Applications/MacPorts/OMEdit.app

Same error.

open /Applications/MacPorts/OMEdit.app/Contents/MacOS/OMEdit

Same error

/Applications/MacPorts/OMEdit.app/Contents/MacOS/OMEdit 
dyld: Library not loaded: @rpath/libqjson.dylib
  Referenced from: /Applications/MacPorts/OMEdit.app/Contents/MacOS/OMEdit
  Reason: image not found
Trace/BPT trap: 5

Same error at the command line

comment:8 by Martin Sjölund, 11 years ago

I meant open /opt/local/Applications/OMEdit.app (the pre-built binaries use a macports prefix of /opt/openmodelica to not interfere. The reason why I wanted to check this is because there are symlinks in these places and I wanted to know how it affects the @rpath lookup.

/Applications/MacPorts/OMEdit.app/Contents/MacOS/../../../../lib/omc does not exist. But /opt/local/Applications/OMEdit.app/Contents/MacOS/../../../../lib/omc should exist...

comment:9 by Adam Dershowitz <dersh@…>, 11 years ago

/opt/local/Applications does not exist
/Application/MacPorts/OMEdit.app does exist, and is where I normally run it from.
But, /Applications/MacPorts/OMEdit.app/Contents/MacOS/ only contains a single file: OMEdit, an executable. It doesn't contain any subdirectories. Going "up" directories from there, can't get to lib/omc, because that lives in /opt/local.

comment:10 by Adam Dershowitz <dersh@…>, 11 years ago

But, this does exist:
/Applications/MacPorts/OMEdit.app/Contents/MacOS/../../../../../opt/local/lib/omc

And, clearly, was being found correctly in r20221, even though otool doesn't show anything with @rpath.

This is for r20221, which runs fine, so must be finding the libraries in /opt/local/lib/omc/:

otool -L /Applications/MacPorts/OMEdit.app/Contents/MacOS/OMEdit 
/Applications/MacPorts/OMEdit.app/Contents/MacOS/OMEdit:
	/opt/local/lib/libomniORB4.1.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/libomnithread.3.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
	/opt/local/lib/libqwt.5.dylib (compatibility version 5.2.0, current version 5.2.3)
	/opt/local/Library/Frameworks/QtWebKit.framework/Versions/4/QtWebKit (compatibility version 4.9.0, current version 4.9.4)
	/opt/local/Library/Frameworks/QtSvg.framework/Versions/4/QtSvg (compatibility version 4.8.0, current version 4.8.5)
	/opt/local/Library/Frameworks/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.5)
	/opt/local/Library/Frameworks/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.5)
	/opt/local/Library/Frameworks/QtXml.framework/Versions/4/QtXml (compatibility version 4.8.0, current version 4.8.5)
	/opt/local/Library/Frameworks/QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.8.0, current version 4.8.5)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)

comment:11 by Adam Dershowitz <dersh@…>, 11 years ago

Maybe this is helpful, to figure it out. omc does live in /opt and does use @rpath.
for r20221:

otool -L  /opt/local/bin/omc
/opt/local/bin/omc:
	@rpath/libOpenModelicaRuntimeC.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libmsgpackc.2.dylib (compatibility version 3.0.0, current version 3.0.0)
	/opt/local/lib/libomniORB4.1.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/libomnithread.3.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
	@rpath/libfmilib_shared.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.2.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
	/opt/local/lib/liblpsolve55.dylib (compatibility version 5.5.0, current version 5.5.0)
	/opt/local/lib/libexpat.1.dylib (compatibility version 8.0.0, current version 8.0.0)

And r20332 looks the same.

comment:12 by Martin Sjölund, 11 years ago

OK, so /Applications/MacPorts is not a symbolic link. I must have read the installation scripts wrong. I guess the only way is to put some absolute paths in the executable...

comment:13 by Adam Dershowitz <dersh@…>, 11 years ago

Nope. It's an actual folder. Macports tries to keep all of the binaries in /opt/local/bin but allows for actual applications to be actually copied into /Applications/MacPorts.
Perhaps it would be possible to put a symbolic link in the executable to point to lib/omc? But, I'm not sure that really helps.

comment:14 by Martin Sjölund, 11 years ago

Well. That's what the rpath does. You link with a list of directories to search for libraries in. But you usually use relative paths so you can move /opt/local to /opt/somethingelse and everything would still work.
What is needed since the Applications directory is totally separate is add the absolute path of lib/omc. r20334 hopefully works. Only when the executable is installed in the expected location, but that should be fine I suppose.

comment:15 by Adam Dershowitz <dersh@…>, 11 years ago

I will try r20334, as soon as that change gets to me. (It often takes a little while until a sync gets the new code.)
I realized another option. You can just add an rpath to actually search. So, after doing this:

sudo install_name_tool -add_rpath /opt/local/lib/omc /Applications/MacPorts/OMEdit.app/Contents/MacOS/OMEdit

OMEdit does now open. Although, it behave the same as when I had tried to just change the name. In other words, when I run a simulation, I get a dyld error in my Output window.
The advantage of doing it this way is that it just adds an additional search path to the binary, without getting rid of any, so it should work either way.

comment:16 by Martin Sjölund, 11 years ago

Yeah, the simulation issue is separate. I wanted to fix OMEdit first.

comment:17 by Martin Sjölund, 11 years ago

r20336 should fix the simulations.

comment:18 by Adam Dershowitz <dersh@…>, 11 years ago

YES!
It now runs again, and simulation now run as well.

Martin, thanks for all the help!

comment:19 by Martin Sjölund, 11 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.