Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

How do I fix Code::Blocks sh: 1: Syntax error: "(" unexpected


  • Please log in to reply
8 replies to this topic

#1 ifunction

ifunction

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:12:34 PM

Posted 21 January 2016 - 09:31 AM

Hello,

 

I have found similar errors online, but none of the solutions have resolved this error. I left a comment asking about this and the reply was that is seems sh related. I use zsh and Code::Blocks' uses sh.

 

I'm getting the following error,

 

sh: 1: Syntax error: "(" unexpected

Process returned 2 (0x2

 

, when I run the following code (learncpp.com) in Code::Blocks 13.12:

#include <iostream>

int doubleNumber(int x)
{
    return 2 * x;
}

int main()
{
    using namespace std;
    int x;
    cin >> x;
    cout << doubleNumber(x) << endl;
    return 0;
}

Kernel: 3.16.0-38-generic i686 (32 bit)

Xfce 4.12.2

 

Code::Blocks Environment settings:

 

Shell to run commands in:                    /bin/sh -c

Terminal to launch console programs:  xterm-T $TITLE -e


Edited by ifunction, 21 January 2016 - 09:31 AM.


BC AdBot (Login to Remove)

 


#2 myrti

myrti

    Sillyberry


  • Malware Study Hall Admin
  • 33,779 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:At home
  • Local time:07:34 PM

Posted 21 January 2016 - 10:00 AM

Hi ifunction,

 

it looks as if you're trying to run a C program with sh, this will not work. You would need to compile it first.

 

regards

myrti


is that a bird?  a plane? nooo it's the flying blueberry!

If I have been helping you and haven't replied in 2 days, feel free to shoot me a PM! Please don't send help request via PM, unless I am already helping you. Use the forums!

 

Follow BleepingComputer on: Facebook | Twitter | Google+


#3 ifunction

ifunction
  • Topic Starter

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:12:34 PM

Posted 21 January 2016 - 10:28 AM

Thanks for the reply,

 

I haven't changed any settings, myrti. This is the default setup for Code::Blocks. I have registered with the Code::Blocks forum, but the moderator has yet to grant me forum access --- it's been a week since I registered/verified my email address.


Edited by ifunction, 21 January 2016 - 10:29 AM.


#4 myrti

myrti

    Sillyberry


  • Malware Study Hall Admin
  • 33,779 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:At home
  • Local time:07:34 PM

Posted 21 January 2016 - 10:30 AM

Hi,

 

how do you try to run the program?


is that a bird?  a plane? nooo it's the flying blueberry!

If I have been helping you and haven't replied in 2 days, feel free to shoot me a PM! Please don't send help request via PM, unless I am already helping you. Use the forums!

 

Follow BleepingComputer on: Facebook | Twitter | Google+


#5 ifunction

ifunction
  • Topic Starter

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:12:34 PM

Posted 21 January 2016 - 10:35 AM

Here's the Build menu:

 

Build

Run

Compile current file

Build and run

Rebuild

 

 

None of these corrects the error.

 

-----

 

-------------- Clean: Debug in doubleNumber() (compiler: GNU GCC Compiler)---------------

Cleaned "doubleNumber() - Debug"

-------------- Build: Debug in doubleNumber() (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -g -std=c++11  -c "/home/m/CBprojects/doubleNumber()/main.cpp" -o obj/Debug/main.o
g++  -o "bin/Debug/doubleNumber()" obj/Debug/main.o   
Output file is bin/Debug/doubleNumber() with size 24.19 KB
Process terminated with status 0 (0 minute(s), 3 second(s))
0 error(s), 0 warning(s) (0 minute(s), 3 second(s))
 

-------------- Run: Debug in doubleNumber() (compiler: GNU GCC Compiler)---------------

Checking for existence: /home/m/CBprojects/doubleNumber()/bin/Debug/doubleNumber()
Executing: xterm -T doubleNumber() -e /usr/bin/cb_console_runner LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. /home/m/CBprojects/doubleNumber()/bin/Debug/doubleNumber()  (in /home/m/CBprojects/doubleNumber()/.)
Process terminated with status 0 (0 minute(s), 2 second(s))
 
 


Edited by ifunction, 21 January 2016 - 10:41 AM.


#6 myrti

myrti

    Sillyberry


  • Malware Study Hall Admin
  • 33,779 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:At home
  • Local time:07:34 PM

Posted 21 January 2016 - 10:45 AM

Ah, try to remove the () in the path: 

/home/m/CBprojects/doubleNumber()/bin/Debug/doubleNumber()

 

The compilation seems to have worked though, although it compiles main instead of learncpp?

 

regards

myrti


is that a bird?  a plane? nooo it's the flying blueberry!

If I have been helping you and haven't replied in 2 days, feel free to shoot me a PM! Please don't send help request via PM, unless I am already helping you. Use the forums!

 

Follow BleepingComputer on: Facebook | Twitter | Google+


#7 ifunction

ifunction
  • Topic Starter

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:12:34 PM

Posted 21 January 2016 - 04:18 PM

:hysterical: Thanks, myrti. I totally missed that. learncpp.com, I forgot the .com. This is the C++ site I'm using to learn C++. I don't see a solved/closed option for this thread.

 

-------------- Build: Debug in doubleNumber (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -g -std=c++11  -c /home/m/CBprojects/doubleNumber/main.cpp -o obj/Debug/main.o
g++  -o bin/Debug/doubleNumber obj/Debug/main.o   
Output file is bin/Debug/doubleNumber with size 24.18 KB
Process terminated with status 0 (0 minute(s), 4 second(s))
0 error(s), 0 warning(s) (0 minute(s), 4 second(s))
 

-------------- Run: Debug in doubleNumber (compiler: GNU GCC Compiler)---------------

Checking for existence: /home/m/CBprojects/doubleNumber/bin/Debug/doubleNumber
Executing: xterm -T doubleNumber -e /usr/bin/cb_console_runner LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. /home/m/CBprojects/doubleNumber/bin/Debug/doubleNumber  (in /home/m/CBprojects/doubleNumber/.)
Process terminated with status 0 (0 minute(s), 29 second(s))
 
 


Edited by ifunction, 21 January 2016 - 04:21 PM.


#8 myrti

myrti

    Sillyberry


  • Malware Study Hall Admin
  • 33,779 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:At home
  • Local time:07:34 PM

Posted 21 January 2016 - 04:23 PM

Hi,

 

it looks like the compiling is working fine (this is also the output i get from what you've posted and the code compiled fine on my machine).. I'm not sure where you're getting the error message from, but it's a problem of how to use code:blocks more than a progrmming issue at this point.

 

regards

myrti


is that a bird?  a plane? nooo it's the flying blueberry!

If I have been helping you and haven't replied in 2 days, feel free to shoot me a PM! Please don't send help request via PM, unless I am already helping you. Use the forums!

 

Follow BleepingComputer on: Facebook | Twitter | Google+


#9 AceInfinity

AceInfinity

  • Members
  • 30 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Canada
  • Local time:10:34 AM

Posted 14 February 2016 - 10:27 PM

g++  -o bin/Debug/doubleNumber obj/Debug/main.o  

It should take main.o object file and output doubleNumber as an executable. Check to see that it exists within the specified folder.


Edited by AceInfinity, 14 February 2016 - 10:31 PM.

mvp.png
Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users