Sunday, 15 September 2013

Sublime Text build file for C++11 -



Sublime Text build file for C++11 -

i'm trying set build scheme in sublime text compile c++11 code , additionally utilize libpqxx library postgres database stuff.

right now, without c++11, g++ command looks this:

"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}", "-i/usr/include/pqxx", "-lpqxx", "-lpq"]

which works fine.

now add together "-std=c++0x" line, , doesn't work. however, wrote simple testprogram has #include <regex> in it, startet out default build file , added c++11 flag this:

"cmd": ["g++", "-std=c++0x", "${file}", "-o", "${file_path}/${file_base_name}"]

it works fine.

i tried running build terminal, using line:

g++ connect.cpp -o connect -std=c++0x -i/usr/include/pqxx -lpqxx, -lpq

but no luck either.

further tried different places -std=c++0x. right after g++, after input , output file names, after include, after libary linking. , trief alter std flag -std+gnu++11, -std=c++11, -std=gnu++0x. nil helped.

what doing wrong?

(by way gcc/g++ has version 4.9, there shouldn't problems c++11 itself. testfile.cpp without lipqxx include , linking works mentioned before)

the solution: -i/usr/include/pqxx needed taken out.

indeed, solution remove -i/usr/include/pqxx. why?

the file wants include /usr/include/pqxx/pqxx. including #include <pqxx/pqxx> (he didnt provide info on stackoverflow). include statement doesn't need additional include path since /usr/include in standard path.

but why build failing?

% ~ cpp -wall -std=c++11 -m test.cpp > test2 % ~ cpp -wall -std=c++11 -i/usr/include/pqxx -m test.cpp > test % ~ cat test2 | sed "s/ \\\\//g" | sed "s/ /\n/g" | sort > test2 % ~ cat test | sed "s/ \\\\//g" | sed "s/ /\n/g" | sort > test % ~ diff test test2 235d234 < 270a270 > /usr/include/c++/4.9.0/array 404a405 > /usr/include/c++/4.9.0/tuple 496d496 < /usr/include/pqxx/tuple

the -m alternative outputs makefile.compatible list of headerfiles. rest reformating have nicer diff.

result: -i/usr/include/pqxx pqxx/tuple included instead of standard c++ tuple. causes compilation errors didnt provide here.

c++11 build g++ sublimetext3

No comments:

Post a Comment