4
kind "SharedLib"
language "C++"
defines "DLL_EXPORT"
targetname "read_cad_file"
targetextension ".arx"

I am developing using objectARX, and I want to compile my project using premake5 and vs2015. Some of the settings in the script is as the above. Under this setting, in properties->C/C++->Code Generation->Runtime Library, the runtime library is Multithreaded Debug(/MTd). I would like to ask how to change it to Multithreaded DLL (/MD) using premake5? Thanks a lot:)

summer
  • 41
  • 1
  • 3

6 Answers6

6

In order to change the runtime library in premake, you need to use two keywords - staticruntime and runtime.

To use /MT in premake:

staticruntime "on"
runtime "Release"

To use /MTd in premake:

staticruntime "on"
runtime "Debug"

To use /MD in premake:

staticruntime "off"
runtime "Release"

To use /MDd in premake:

staticruntime "off"
runtime "Debug"
Albin
  • 169
  • 3
  • 9
3

The key you are looking for is staticruntime. While it should be off by default, you can also turn it off explicitly

As in

staticruntime "Off"
Sty
  • 760
  • 1
  • 9
  • 30
1
   configuration "Debug"
      buildoptions "/MDd"
   configuration "Release"
      buildoptions "/MD"
   configuration {}
Dmytro Dadyka
  • 2,208
  • 5
  • 18
  • 31
0

I don't know about the static or DLL versions of the runtime. But debug and release should be switchable by the runtime keyword. See:

https://github.com/premake/premake-core/wiki/runtime

Florian Zwoch
  • 6,764
  • 2
  • 12
  • 21
0

So, my project isn't a shared lib, but an exe.

What I added was the following to the 'filter' section:

filter "configurations:Debug"
    architecture "x86_64"
    links {"libprotobufd"}
    defines {"DEBUG"}
    symbols "On"
    libdirs { baseLibPath .. "debug" } -- baseLibPath was defined elsewhere
    postbuildcommands {}
    debugdir "$(TargetDir)"
    flags {"staticruntime"} -- this is what worked for me

I'm not sure if that will solve your problem, but give it a go?

I'm still relatively new to premake, so take this with a grain of salt.

-1
project "read_cad_file"
  kind "SharedLib"
  language "C++"
  defines "DLL_EXPORT"
  targetname "read_cad_file"
  targetextension ".arx"
  files "*.cpp"
  files "*.def"
  files "*.lua"
  sysincludedirs "../../../third_party/object_arx/inc-x64/"     
  sysincludedirs "../../../third_party/object_arx/inc/"
  includedirs "../../../third_party/object_arx/inc/"
  includedirs "../../../third_party/object_arx/inc-x64/"
  libdirs "../../../third_party/object_arx/lib-x64/"
  links "ac1st22.lib"
  links "acad.lib"
  links "accore.lib"
  links "acdb22.lib"
  links "acge22.lib"
  links "acgiapi.lib"
  links "acui22.lib"
  links "adui22.lib"
  links "advapi32.lib"
  links "rxapi.lib"

This is the full premake file.

summer
  • 41
  • 1
  • 3