Sublime Forum

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

#1

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]#include
using namespace std;

int main()
{
cout << “Hello World”;
return 0;
} [/code]

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

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.

0 Likes

#2

duh, I found the solution… I was putting the main() in the .h file instead of cpp. Sorry about that.

0 Likes