1

I'm trying to run executable files on Ubuntu, but it's not working, although the exact same executable file works fine on others' machines, which are also running Ubuntu 12.04 like me. Based on this, I asked a question here: Executing compiled file on Ubuntu

But now I realize the issue isn't in my compiled file. Because I wrote a very simple .cpp file and tested it, but Ubuntu still didn't run it.

This is my simple test.cpp:

#include <stdio.h>
#include <stdlib.h>

int main( int argc, char **argv ) 
{
 printf ("Hello, this test worked!");
return 0;
}

Then I compiled it:

g++ `pkg-config --cflags opencv` -o test test.cpp

And then tried to run it:

./test

But I get an error:

bash: ./test: Permission denied

So I try with sudo:

sudo ./test

which asks me for my user password, which I give, but then it says:

sudo: ./test: command not found

So how can I run executable files at all?

Edit

I've got this Ubuntu installed on top of Windows, using the Wubi installer.

When I run:

pkg-config --cflags opencv

I get this:

-I/usr/local/include/opencv -I/usr/local/include  

When I run

df .

It says:

Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/loop0      17596475 6112377  11484098  35% /

And when I run:

cat /proc/mounts

Then this is the output:

rootfs / rootfs rw 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
udev /dev devtmpfs rw,relatime,size=1944900k,nr_inodes=486225,mode=755 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,relatime,size=781788k,mode=755 0 0
/dev/sda4 /host fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other,blksize=4096 0 0
/dev/loop0 / ext3 rw,relatime,errors=continue,user_xattr,acl,barrier=1,data=ordered 0 0
none /sys/fs/fuse/connections fusectl rw,relatime 0 0
none /sys/kernel/debug debugfs rw,relatime 0 0
none /sys/kernel/security securityfs rw,relatime 0 0
none /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
none /run/shm tmpfs rw,nosuid,nodev,relatime 0 0
gvfs-fuse-daemon /home/asaaki/.gvfs fuse.gvfs-fuse-daemon rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
11
  • What does ls -l test say?
    – cjm
    Apr 8, 2014 at 15:50
  • It says: -rw------- 1 asaaki asaaki 8380 Apr 8 18:16 test . "asaaki" is the user, me. But this is after I've already run: sudo chmod -x test and sudo chmod 755 test.
    – user961627
    Apr 8, 2014 at 15:53
  • What does umask say?
    – cjm
    Apr 8, 2014 at 15:54
  • 1
    Your umask looks ok. chmod -x removes the executable permission. You'd do chmod +x to add it.
    – cjm
    Apr 8, 2014 at 15:56
  • 1
    What's the output of pkg-config --cflags opencv? What filesystem are you doing this on: the Linux filesystem, or a Windows filesystem? Post the output of df . and cat /proc/mounts. Apr 8, 2014 at 23:11

1 Answer 1

-1

Aren't you compiling it wrong? Shouldn't it be like:

g++ `pkg-config --cflags opencv` -o test.cpp test

or

g++ `pkg-config --cflags opencv` test.cpp -o  test
1
  • It certainly shouldn't be like your first suggestion; that would try to compile a file called test (the intended output) and store the result in a file called test.cpp (the intended input).
    – Celada
    Aug 17, 2014 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.