Sublime Forum

Running a C++ Program with libraries via Build System

#1

The (C++) program I want to compile relies on some boost libraries. I’ve managed to create a build system that can build
the program successfully, but the run variant does not work. Specifically, I believe it has issues locating the library / passing on the
library arguments to the compiler.

[code]{
“cmd”: “g++”, “${file}”, “-o”, “${file_path}/${file_base_name}”, “-I/usr/local/include”, “-L/usr/local/lib”, “-lboost_system”],
“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}' && '${file_path}/${file_base_name}' -L/usr/local/lib -L/usr/local/lib -lboost_system"]
	}
]

}
[/code]

Error:

Undefined symbols for architecture x86_64: "boost::system::system_category()", referenced from: __static_initialization_and_destruction_0(int, int)in ccT6YF4S.o boost::asio::error::get_system_category() in ccT6YF4S.o "boost::system::generic_category()", referenced from: __static_initialization_and_destruction_0(int, int)in ccT6YF4S.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status [Finished in 1.2s with exit code 1]

I’ve tried multiple combinations for the arguments, splitting them up into an array, quotes, no quotes, etc. Yet it still seems to fail to pass the arguments to g++ successfully. Is there a way to pass the arguments to g++ (or anything else to fix the problem), or is this not feasible for a run build.

Thanks.

0 Likes