Home Download Buy Blog Forum Support

cannot execute compiled binary from a c++ .h file

cannot execute compiled binary from a c++ .h file

Postby hrodgair on Thu Jun 27, 2013 3:01 pm

Hi,

just discovered Sublime Text 2. It looks amazing. But I have some trouble running compiled c++ .h files. I just tried compiling and running "hello world":

Code: Select all
#include <iostream>
using namespace std;

int main()
{
   cout << "Hello World";
   return 0;
}   


If I save it as .c and compile and run it, it works fine. But if I save it as .h and try to compile and run I get this error

Code: Select all
bash: /Users/roger/Desktop/tester/helloworld: cannot execute binary file
[Finished in 0.9s with exit code 126]




I'm using the default c++ build system. I'm on OSX 10.8.4. Any clues on what may I be doing wrong?

Cheers.
hrodgair
 
Posts: 3
Joined: Thu Jun 27, 2013 2:52 pm

Re: cannot execute compiled binary from a c++ .h file

Postby hrodgair on Fri Jun 28, 2013 5:46 pm

duh, I found the solution... I was putting the main() in the .h file instead of cpp. Sorry about that.
hrodgair
 
Posts: 3
Joined: Thu Jun 27, 2013 2:52 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 19 guests