Sublime Forum

C++ and boost library compile and Run on Mac

#1

I want to compile and run (showing results in sublime console) customising sublime to use c++ and boost library. I am able to compile but no results are shown in the console. Can you help me?

I wrote the following
{
“cmd” : [“g++”,"${file_path}/${file_base_name}.cpp","-I/opt/local/include","-L/usr/local/lib","-o${file_path}/${file_base_name}.o"],
“selector” : “source.cpp”,
“working_dir”: “${file_path}”,
“shell”: true,
“variants”:
[
{
“name”: “Run”,
“cmd”: ["${file_path}/${file_base_name}.o"]
}
]
}

0 Likes

#2

sample code? expected result?
also, didnt see any -lboostxxxx in your build.
some libs need to be linked.

0 Likes

#3

Even the simple code

#include
int main(int argc,char *argv[]){
std::cout<<“Test”<<"\n";
return 0;
}
does not work properly. If I first compile with
{
“cmd” : [“g++”,"${file_path}/${file_base_name}.cpp","-I/opt/local/include","-L/usr/local/lib","-o${file_path}/${file_base_name}.o"],
“selector” : “source.cpp”,
“working_dir”: “${file_path}”
}
and then I add the last part with “shell” and “variants” and recompile the c++ file everything works correctly and I am able to see results on the console. However with a new c++ file I have to redo this procedure. Is there something wrong in my user package file?

0 Likes

#4

Does it compiles successfully and output a .o file with your full build settings?
Also, shouldn’t the scope "selector" : "source.cpp", be source.c++ for the default package?

0 Likes

#5

You’re right…no .o file is created with the full build settings, while if I remove the Run part it generates the output file. I use Sublime 3 on a Mac OSX.

Anyway apparently there is no differences if I change the selector to c++ instead of cpp.

Maybe I am making some mistake? I think I still don’t understand how to write correctly the build setting file

0 Likes