Sublime Forum

Build system -> DLL -> C++ -> solved

#1

Hi,

I have created a C++ DLL in Visual Studio (2015) and try to compile/create the DLL with sublime text - unfortunatly without success yet.

These are the used files:

  • testDLL.cpp (DLL-file, #include “stdafx.h”)
  • stdafx.h (Header-file, #include “targetver.h”, #include <windows.h>)
  • targetver.h (Header-file, #include <SDKDDKVer.h>)

As I already installed Visual Studio with the Microsoft cl.exe compiler, I like to use cl.exe as compiler and tried with the following build systems.

Build system 1 (works for cpp-files but not for the DLL):

[code]{
“cmd”: “vcvars32.bat”, “&”, “cl”, “/EHsc”, “${file}”],
“file_regex”: “^(…^:]):([0-9]+):?([0-9]+)?:? (.)$”,
“working_dir”: “${file_path}”,
“selector”: “source.c, source.cpp, source.c++”,
“shell”: true,

"variants":

	{
		"name": "Run",
		"cmd": "vcvars32.bat", "&", "cl", "/EHsc", "${file}", "&", "${file_path}/${file_base_name}.exe"]
	}
]

}[/code]

Error from compiler with build system 1:

LINK : fatal error LNK1561: Entry point must be defined.

Build system 2 (based on this tutorial: https://sumeetiitg.wordpress.com/2013/12/16/how-to-make-and-use-a-dll-using-command-line-and-cl-compiler/ ):

[code]{
“cmd”: “cl.exe /LD ${file} ${file_path}\${file_base_name}.dll”],
“file_regex”: “^(…^:]):([0-9]+):?([0-9]+)?:? (.)$”,
“working_dir”: “${file_path}”,
“selector”: “source.c, source.cpp, source.c++”,
“shell”: true,

"variants":

	{
		"name": "Run",
		"cmd": "vcvars32.bat", "&", "cl", "/EHsc", "${file}", "&", "${file_path}/${file_base_name}.exe"]
	}
]

}[/code]

Sublime shows no errors and DLL is not created. If I use the consol the following error is displayed with build system 2:

fatal error C1034: SDKDKVer.h: No include path set.

Can anyohne help me to get it work without using Visual Studio?

Regards,
Martin

Edit ++++
I just solved the problem. I have to combine the to build systems like this:

{ "cmd": "vcvars32.bat", "&", "cl", "/LD", "${file}"], "file_regex": "^(..^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}", "selector": "source.c, source.cpp, source.c++", "shell": true, }

0 Likes

#2

You can run vcvars32.bat on startup of the the command line and then run sublime text from the command line. This way you don’t have to call vcvarss32,bat each time you build.

e.g. a desktop shortcut I use:

C:\Windows\System32\cmd.exe /k u:\scripts\shell.bat

vcvars is called in shell.bat.

0 Likes