premake / premake-4.x

Premake 4
BSD 3-Clause "New" or "Revised" License
74 stars 20 forks source link

When creating a shared library (dll) on WIndows, a small static library is also created #14

Closed SMSteven closed 6 years ago

SMSteven commented 6 years ago

When creating a shared library (MathLib.dll) on Windows using premake4, and running the generated makefile, in fact 2 targets are created: MathLib.dll (25 KB) and a file (libMath.a of 2 KB size). The libMath.a file seems to be a dummy (empty) static library, since it is only of 2K size. Also it isn’t cleaned up when executing premake clean.

What's happening is that when I create a shared library using premake4, it creates it alright, but it also creates a dummy static library! In fact, this is more serious than it sounds, because if there had been a (genuine) static library of that name in the directory containing the libraries, then when I run premake to create a shared library, the new (dummy/empty) static library erroneously created by premake, OVERWRITES AND REPLACES the genuine static library of the same name that was already existing in the dir.

A workaround may be to avoid creating the libraries in a common dir initially, but instead create in a separate (local) dir, perhaps the same as the one containing the (shared library creation) source files and then copy the (genuine) library to the final common library dir.

Is there any way to prevent creation of this spurious static library?

The premake file contains:

`solution "MathLib" configurations { "Debug", "Release" }

-- A project defines one build target project "MathLib" kind "SharedLib" language "C++" files { ".h", ".cpp" } -- Create target library in Files > C > SW > -- Applications > ProgramLibraries targetdir "../../../ProgramLibraries/"

  configuration "Debug"
     defines { "DEBUG" }
     flags { "Symbols" }

  configuration "Release"
     defines { "NDEBUG" }
     flags { "Optimize" }

-- Register the "runmakefile" action. newaction { trigger = "runmakefile", description = "run the generated makefile to create the executable using the default (debug config)", execute = function() os.execute("make") end }

-- Register the "runmakefilerelease" action. newaction { trigger = "runmakefilerelease", description = "run the generated makefile to create the executable using the 'release' config)", execute = function() os.execute("make config=release") end }`

starkos commented 6 years ago

That's the import library. You can turn it off with the NoImportLib flag.

Feel free to re-open if that's not clear.