Блог пользователя maverick_xiii

Автор maverick_xiii, 10 лет назад, По-английски

Since the Sublime text 3 build 3083 update, short-cuts for building and running single file C++ programs have changed. If you loved the old shortcuts (cmd+b to compile and cmd+shift+b to run), you can restore them by adding these custom key bindings.

	{
		"keys": ["super+b"], 
		"command": "build",
		"context": [
			{ "key": "selector", "operator": "equal", "operand": "source.c++" }
		], 
		"args": {
			"build_system": "Packages/C++/C++.sublime-build",
			"variant": "Build"
		}
	},
 
	{
		"keys": ["super+shift+b"], 
		"command": "build",
		"context": [
			{ "key": "selector", "operator": "equal", "operand": "source.c++" }
		],
		"args": {
			"build_system": "Packages/C++/C++.sublime-build",
			"variant": "Run"
		}
	},

	{
		"keys": ["super+b"], 
		"command": "build",
		"context": [
			{ "key": "selector", "operator": "equal", "operand": "source.java" }
		], 
		"args": {
			"build_system": "Packages/Java/Java.sublime-build",
			"variant": "Build"
		}
	},
 
	{
		"keys": ["super+shift+b"], 
		"command": "build",
		"context": [
			{ "key": "selector", "operator": "equal", "operand": "source.java" }
		],
		"args": {
			"build_system": "Packages/Java/Java.sublime-build",
			"variant": "Run"
		}
	}

Hope this helps :)

EDIT: The previous script I mentioned had a bug : The short-cut keys were executing c++ build command even for java source code. I have resolved that bug using 'context'. 'context' helps link multiple build_systems / commands with same short-cuts. So this should do the trick. And any undefined build_systems here would be executing default behaviour for the short-cuts :)

  • Проголосовать: нравится
  • +14
  • Проголосовать: не нравится

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Well can you help me to solve my problem of running C++ in Sublime text 2? It shows an error of this kind. g++: fatal error: -fuse-linker-plugin, but liblto_plugin-0.dll not found compilation terminated.

I downloaded MinGW and then added the bin address to the environment variables in advanced system settings in Windows 8.1.. Can you help??

  • »
    »
    10 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    In your 'Packages' folder you should have the 'C++/C++.sublime-build' file for the script to work. Please let me know if you have it.

    • »
      »
      »
      10 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Yes.. In preferences->Browse packages right?? I have it !!

      • »
        »
        »
        »
        10 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Then the problem seems to be in your C++.sublime-build. Try this in your C++.sublime-build.

            {
                "path": "c:\\Program Files\\MinGW\\bin\\",
                "cmd": ["mingw32-g++.exe", "-static", "-o", "$file_base_name", "$file"]
            }
        
        • »
          »
          »
          »
          »
          10 лет назад, # ^ |
          Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

          And do i just add this to the existing code in it or replace the whole code??

          • »
            »
            »
            »
            »
            »
            10 лет назад, # ^ |
              Проголосовать: нравится 0 Проголосовать: не нравится

            modify your existing code with above parameters. "path" is the path to your 'bin' folder in MinGW.

»
9 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

how and where to enter input?

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    You can add a command to run your compiled program from XTerm, or whatever terminal depending on your OS

»
6 лет назад, # |
  Проголосовать: нравится -10 Проголосовать: не нравится

Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) [Finished in 0.1s with exit code 1] [cmd: ['g++', '-std=c++0x', '/Users/OptiMaze/Documents/ut.cpp', '-o', '/Users/OptiMaze/Documents/ut']] [dir: /Users/OptiMaze/Documents] [path: /Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/OptiMaze/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

i am getting this message while running my c++ code. Can anyone help me with this?

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

How to comment a block of C++ code in sublime text 3?