Trying to compile and run a simple Allegro program using Sublime Text 2 and SublimeClang. If I run g++ '/path/to/project/main.cpp' -o '/path/to/project/main' -I/usr/include/allegro5 -L/usr/lib -lallegro
on the command line, it compiles fine.
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' $(pkg-config --libs allegro-5.0)"]
}
]
}
Running bash -c g++ '/path/to/project/main.cpp' -o '/path/to/project/main' && '/path/to/project/main' -I/usr/include/allegro5 -L/usr/lib -lallegro
It seems that Sublime is adding && '/path/to/project/main'
, even though the build settings don't specify to do that. What is causing Sublime to add this && '/path/to/project/main'
? And how do I remove it?
In the bigger picture - this means Allegro will be linked in all C++ projects even if the libraries aren't being used. Is there a way to add the Allegro flags globally on my system? Sorry, not usually a C++ dev.
I solved my own issue. I used backticks instead of the $()
notation:
"cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' `pkg-config --libs allegro-5.0` && ./${file_base_name}"]
Notice I also added && ./${file_base_name}
- which runs the program too.