LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-13-2011, 07:29 AM   #1
elenax
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Rep: Reputation: 0
Problems with running a c++ file in linux


Hi!

I have used Tangible Software Soultion's tool to translate a C# code to C++, which resulted in:

//Welcome.h

#include <iostream>
using namespace std;

// Program start class
class WelcomeCSS
{
// Main begins program execution.
static void Main()
{
// Write to console
std::cout << "Welcome to the C# Station Tutorial!" << std::endl;
}
};

When I run it on my linux system, I get the error "Permission denied". I am new to C++ and new to Linux. What could possibly be wrong? I can run another C++ code from the same location without any trouble. Thank you your help!

[dikkanen@saturn example]$ g++ Welcome.h -o Welcome
[dikkanen@saturn example]$ ./Welcome
bash: ./Welcome: Permission denied

~ Elena

Last edited by elenax; 03-13-2011 at 07:30 AM.
 
Old 03-13-2011, 07:58 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,254

Rep: Reputation: 314Reputation: 314Reputation: 314Reputation: 314
You need to make file executable.
Code:
chmod +x ./Welcome
 
Old 03-13-2011, 07:59 AM   #3
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Before going any further, is your Welcome file executable? You can find out by performing the following:
Code:
ls -al
If it is not, you need to chmod +x the file, as so:
Code:
chmod +x Welcome
Edit - eSelix beat me to it. I guess I'm losing the battle today...
 
Old 03-13-2011, 08:10 AM   #4
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,254

Rep: Reputation: 314Reputation: 314Reputation: 314Reputation: 314
By the way I just compiled this program. First you can't execute compiled header (.h) file, maybe there are some switch to recognize it as .cpp. It need this extension to be compiled as C++ file. The second if you want to execute it must contain global function main()
Code:
int main(void)
{
// Code here
}
corp769: Sorry, I do not understand this words: "beat me to it". My english is not very good.

Last edited by eSelix; 03-13-2011 at 08:13 AM.
 
Old 03-13-2011, 08:38 AM   #5
elenax
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you all! I discovered that the tool was set up to output only header file. Now I have succeeded to get cpp files and could compile. Yes, still get en error of no main. I will go back to my original C# file and see if it had main in the first place. Thank you all!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems running batch file Poison Ivy 30 Linux - Newbie 3 01-16-2009 02:23 AM
Problems installing and running Frostwire on Acer One running Linpus Linux ricky1981 Linux - Newbie 1 12-19-2008 08:24 AM
running file from root and running file from user kedar Linux - Newbie 2 09-16-2008 01:59 AM
I'm Running Linux (SuSE 9.1), which file do I download? skydart Linux - General 7 08-25-2004 11:35 PM
graphical problems while running linux deathsythe210 Linux - Hardware 3 07-28-2004 08:13 PM


All times are GMT -5. The time now is 03:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration