c++ - Running a compiled executable in Xcode gives a different result from directly invoking the executable in the shell -
The program uses OpenCGraph to generate the OSSG file.
int main (int, char **) {osg :: ref_ptr & lt; Osg :: node & gt; Root = createSceneGraph (); If (! Root.valid ()) {osg :: notify (osg :: FATAL) & lt; & Lt; "Failed to create" & Lt; & Lt; Endl; } Bool result = osgDB :: writeNodeFile (* (root.get ()), "simple.OSG"); If (! Result) {osg :: Notify (OSS :: FATAL) & lt; & Lt; "OsgDB :: writeNode () failed." & Lt; & Lt; Endl; }}
code extract is from the openscenegraph Quick Start Guide page 40
The program can be compiled and Running in XCode but, it shows the following error:
Error writing file Simple.osg: Warning: The "Simple.osg" file could not get the plugin to write nodes. OsgDB :: writeNode () failed.
However , compile binary to without error directly run in shell. (./program) and programmatically simplified.O.O. Generates file.
This is not the end of the story, it is most likely because the encoded callile program invokes the program differently from opening it in shell. Therefore, I copy and paste two dependent libraries into the directory where the compiled binary remains.
(If the OSG knows, then there are two libraries osgdb_deprecated_osg.so and osgdb_osg.so)
At this time, Xcode runs the program correctly without any error, generates a Simple.osg file is.
Therefore, there are two questions
1) Why is Shell able to automatically detect dependent libraries while not able to encode?
2) How to manually copy the dependent libraries by copying or posting Xcode work Copy compilation options?
This is only a case of shell path in Shell and Xodod.
An IDE will tell you a lot of time how PATH is in use in executable run-time, make sure that it contains all the important entries in the normal shell.
Comments
Post a Comment