Command /bin/sh failed with exit code 2

  • Thread starter Thread starter Monique
  • Start date Start date
  • Tags Tags
    Code
AI Thread Summary
The error "Command /bin/sh failed with exit code 2" occurs during the build process in Xcode, indicating that the project file VTK.xcodeproj cannot be parsed due to an unexpected character at line 1. This suggests that the file is being treated as a script rather than a project file, potentially due to a missing program or misconfiguration in the Makefile. Attempts to install VTK via MacPorts also fail, citing undefined symbols and various build errors related to the VXL dependency. The installation instructions provided are deemed insufficient, leading to frustration over the inability to resolve these issues. Overall, users are encouraged to verify their Xcode setup and ensure all dependencies are correctly configured before attempting to build the project.
Monique
Staff Emeritus
Science Advisor
Gold Member
Messages
4,211
Reaction score
68
I'm trying to build code in Xcode, but I keep getting the following error:

Code:
xcodebuild[17565:903] Unexpected character / at line 1
xcodebuild: error: Unable to read project 'VTK.xcodeproj'.
Reason: Project ../VTK.xcodeproj cannot be opened because the project file cannot be parsed.

make: *** [../VTK-build] Error 74
Command /bin/sh failed with exit code 2

I tried to edit the file causing the error, but I can't see what's wrong with it. Line 1 says: // !$*UTF8*$!

Does anyone have a clue what could be the cause?
 
Technology news on Phys.org
The error means that the system tries to execute the file VTK.xcodeproj as if it is a script file, but it isn't.
It's a project file that should be loaded by some program.
I suspect it means that you are missing a program on your system.

In the file named "Makefile" there should be a line somewhere with the text "VTK.xcodeproj".
It should have something in front of it that is the program to be used to load it.
That may give a hint of what you're missing.

Anyway, you can probably solve it by reading some of the installation instructions.
 
Shouldn't VTK.xcodeproj be able to open in Xcode? I have other .xcodeproj files that do.

The installation instructions are not very helpful. It says to configure and generate the superbuild files in cmake and then make the files with "make -j9". That's it
 
I tried an alternate approach, install via macports. Here I also get an error and again something about undefined symbols? Other software installs just fine, this is annoying.

Code:
$ sudo port install VTK
--->  Computing dependencies for VTK
--->  Fetching archive for VTK
--->  Attempting to fetch VTK-4.4.2_0.darwin_10.x86_64.tbz2 from [PLAIN]http://packages.macports.org/VTK[/PLAIN] 
--->  Fetching VTK
--->  Attempting to fetch VTK-4.4.2.tar.gz from [PLAIN]http://lil.fr.distfiles.macports.org/VTK[/PLAIN] 
--->  Verifying checksum(s) for VTK
--->  Extracting VTK
--->  Applying patches to VTK
--->  Configuring VTK
--->  Building VTK
Error: Target org.macports.build returned: shell command failed (see log for details)
Log for VTK is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_vtk/VTK/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>

Code:
Last part of the log:

:info:build Undefined symbols for architecture x86_64:
:info:build   "_oft_initCommon", referenced from:
:info:build      -init command line option
:info:build ld: symbol(s) not found for architecture x86_64
:info:build collect2: ld returned 1 exit status
:info:build make[2]: *** [bin/libvtkCommon.dylib] Error 1
:info:build make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_vtk/VTK/work/VTK'
:info:build make[1]: *** [Common/CMakeFiles/vtkCommon.dir/all] Error 2
:info:build make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_vtk/VTK/work/VTK'
:info:build make: *** [all] Error 2
:info:build make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_vtk/VTK/work/VTK'
:info:build shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_vtk/VTK/work/VTK" && /usr/bin/make -j4 -w all " returned error 2
:error:build Target org.macports.build returned: shell command failed (see log for details)
:debug:build Backtrace: shell command failed (see log for details)
    while executing
"command_exec build"
    (procedure "portbuild::build_main" line 8)
    invoked from within
"$procedure $targetname"
:info:build Warning: the following items did not execute (for VTK): org.macports.activate org.macports.build org.macports.destroot org.macports.install
:notice:build Log for VTK is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_vtk/VTK/main.log
 
Last edited by a moderator:
Monique said:
Shouldn't VTK.xcodeproj be able to open in Xcode? I have other .xcodeproj files that do.

Did you try to open VTK.xcodeproj with Xcode?
Can you find a reference in the Makefile to VTK.xcodeproj?


The installation instructions are not very helpful. It says to configure and generate the superbuild files in cmake and then make the files with "make -j9". That's it

Did you carefully monitor the build process and check for warnings or errors?
You say "configure", so did you configure anything?
 
I like Serena said:
Did you try to open VTK.xcodeproj with Xcode?
Yes, I get a parse error.
Can you find a reference in the Makefile to VTK.xcodeproj?
no, I don't

Did you carefully monitor the build process and check for warnings or errors?
Yes, I posted it in the first post and again in the later post with the other approach.
You say "configure", so did you configure anything?
I used default settings to generate the build files.

I tried installing another dependency VXL and that fails as well. I'm starting to think the only solution is to wipe my computer clean and install everything from scratch :( which I don't want to do.
 
Let me see if I understand the situation correctly.

Do you have a working Xcode?
Are you programming in Xcode for that matter?
Can you build other projects?

What kind of project is VTK?
Is it a project you downloaded and are building from source?

You said you tried to edit the file causing the error.
Which file did you mean?
 
I like Serena said:
Let me see if I understand the situation correctly.

Do you have a working Xcode?
Are you programming in Xcode for that matter?
Can you build other projects?
yes, yes, yes.

What kind of project is VTK?
Is it a project you downloaded and are building from source?
vtk.org, yes

You said you tried to edit the file causing the error.
Which file did you mean?
VTK.xcodeproj, the file that can not be parsed.

Here is the part of the building process that gives errors and causes the premature abortion of make:
Code:
[ 32%] Building CXX object core/vil/CMakeFiles/vil.dir/file_formats/vil_jpeg.o
[ 32%] Building CXX object core/vil/CMakeFiles/vil.dir/file_formats/vil_jpeg_source_mgr.o
[ 33%] Building CXX object core/vil/CMakeFiles/vil.dir/file_formats/vil_jpeg_decompressor.o
[ 33%] Building CXX object core/vil/CMakeFiles/vil.dir/file_formats/vil_jpeg_destination_mgr.o
[ 33%] Building CXX object core/vil/CMakeFiles/vil.dir/file_formats/vil_jpeg_compressor.o
[ 33%] Building CXX object core/vil/CMakeFiles/vil.dir/file_formats/vil_openjpeg.o
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:107: error: ISO C++ forbids declaration of ‘/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:107: error: expected ‘;’ before ‘*’ token
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:109: error: ISO C++ forbids declaration of ‘opj_stream_t’ with no type
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:109: error: expected ‘;’ before ‘*’ token
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:146: error: ISO C++ forbids declaration of ‘opj_codec_t’ with no type
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:146: error: expected ‘;’ before ‘*’ token
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx: In constructor ‘vil_openjpeg_image_impl::vil_openjpeg_image_impl()’:
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:158: error: class ‘vil_openjpeg_image_impl’ does not have any field named ‘encode_codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx: In constructor ‘vil_openjpeg_decoder::vil_openjpeg_decoder(OPJ_CODEC_FORMAT)’:
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:174: error: class ‘vil_openjpeg_decoder’ does not have any field named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:174: error: class ‘vil_openjpeg_decoder’ does not have any field named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx: In destructor ‘vil_openjpeg_decoder::~vil_openjpeg_decoder()’:
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:186: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:188: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:188: error: ‘opj_stream_destroy’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:189: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:191: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:193: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:193: error: ‘opj_destroy_codec’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:194: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx: In member function ‘bool vil_openjpeg_decoder::init_stream(void*)’:
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:241: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:243: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:243: error: ‘opj_stream_destroy’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:244: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:248: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:248: error: ‘opj_stream_default_create’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:249: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:253: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:253: error: ‘opj_stream_set_user_data’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:254: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:255: error: ‘opj_stream_set_read_function’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:256: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:257: error: ‘opj_stream_set_write_function’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:258: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:259: error: ‘opj_stream_set_skip_function’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:260: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:261: error: ‘opj_stream_set_seek_function’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx: In member function ‘bool vil_openjpeg_decoder::init_decoder(unsigned int)’:
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:271: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:273: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:273: error: ‘opj_destroy_codec’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:274: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:284: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:285: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:289: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:290: error: ‘opj_set_info_handler’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:291: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:292: error: ‘opj_set_warning_handler’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:293: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:294: error: ‘opj_set_error_handler’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:297: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx: In member function ‘bool vil_openjpeg_decoder::read_header()’:
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:316: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:324: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:324: error: ‘opj_read_header’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx: In member function ‘bool vil_openjpeg_decoder::set_decode_area(unsigned int, unsigned int, unsigned int, unsigned int)’:
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:334: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:334: error: ‘opj_set_decode_area’ was not declared in this scope
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx: In member function ‘opj_image_t* vil_openjpeg_decoder::decode()’:/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:353: error: ‘class vil_openjpeg_decoder’ has no member named ‘codec_’
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx:353: error: ‘class vil_openjpeg_decoder’ has no member named ‘stream_’
make[5]: *** [core/vil/CMakeFiles/vil.dir/file_formats/vil_openjpeg.o] Error 1
make[4]: *** [core/vil/CMakeFiles/vil.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [ExternalProjects/Stamp/VXL/VXL-build] Error 2
make[1]: *** [CMakeFiles/VXL.dir/all] Error 2
make: *** [all] Error 2
sh-3.2# make
 
Do these compilation errors occur before the error you had on the unexpected '/'?

What does line 107 say in the following file?
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx
 
  • #10
I like Serena said:
Do these compilation errors occur before the error you had on the unexpected '/'?
These compilation errors I get when I perform make in my terminal window. Sorry, I did not use Xcode in this attempt because I'm trying different things to get to the bottom of it (:smile:) So, the compilation errors in my previous post are the first that I encounter in that attempt.

What does line 107 say in the following file?
/ExternalProjects/Source/VXL/core/vil/file_formats/vil_openjpeg.cxx
It says:
opj_codec_t *codec_;

Thanks so much for thinking along, I never encountered problems before that I couldn't solve.
 
  • #11
Monique said:
It says:
opj_codec_t *codec_;

That would suggest that the type opj_codec_t is unknown.
Since it would have been defined in an earlier include, that suggests a versioning problem.
It seems it should have been defined as part of the openjpeg library (openjpeg.h), which contains similar definitions.
Can you trace where opj_codec_t should come from?
Perhaps a "grep" on the openjpeg include files?

Thanks so much for thinking along, I never encountered problems before that I couldn't solve.

Welcome to the club. :smile:
 
Back
Top