Command /bin/sh failed with exit code 2

  • Thread starter Monique
  • Start date
  • Tags
    Code
In summary, the user is trying to build code in Xcode but keeps getting an error. There is a Makefile with a line that needs to be replaced with the program VTK.xcodeproj to work. There are installation instructions but they are not very helpful. The build process ended in error with a backtrace that says the command failed.
  • #1
Monique
Staff Emeritus
Science Advisor
Gold Member
4,219
67
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
  • #2
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.
 
  • #3
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
 
  • #4
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:
  • #5
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?
 
  • #6
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.
 
  • #7
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?
 
  • #8
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
 
  • #9
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:
 

1. What does the error "Command /bin/sh failed with exit code 2" mean?

This error message means that the shell command being executed has failed and returned an exit code of 2. An exit code of 0 typically indicates successful execution, while non-zero exit codes indicate an error or failure.

2. Why am I getting the error "Command /bin/sh failed with exit code 2"?

There could be multiple reasons for this error, such as incorrect syntax in the shell command, missing dependencies, or insufficient permissions. It is important to review the specific command and its execution environment to determine the cause of the error.

3. How do I fix the error "Command /bin/sh failed with exit code 2"?

The solution to this error depends on the specific cause. Some steps you can take to resolve the issue include checking the syntax of the command, ensuring all necessary dependencies are installed, and granting appropriate permissions. It may also be helpful to consult documentation or seek assistance from a colleague or forum.

4. Can I ignore the error "Command /bin/sh failed with exit code 2"?

In some cases, the error may not have a significant impact on the overall execution of the program or operation. However, it is important to investigate the cause of the error and address any underlying issues to ensure proper functionality and avoid potential problems in the future.

5. How can I prevent the error "Command /bin/sh failed with exit code 2" from occurring?

To prevent this error, it is important to thoroughly test and review shell commands before execution. Additionally, maintaining an updated and properly configured environment with all necessary dependencies can help avoid potential errors. If the error persists, it may be necessary to seek guidance from experienced individuals or seek out alternative solutions.

Similar threads

  • Programming and Computer Science
Replies
2
Views
301
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
12
Views
9K
  • Programming and Computer Science
Replies
9
Views
2K
  • Programming and Computer Science
Replies
4
Views
5K
Replies
16
Views
2K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
9
Views
3K
  • Programming and Computer Science
Replies
4
Views
3K
Back
Top